Source

tinpan / integration / views.py

Full commit
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext, loader
from django.contrib.auth.models import User
from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.contrib.auth.decorators import login_required
from django.db.models import Max
from tinpan.integration.models import Project, BuildRun

def overview(request):
    """An overview of all projects."""
    
    projects = Project.objects.all()
    
    return render_to_response('integration/overview.html',
        { 'projects': projects }, context_instance=RequestContext(request) )

def project_detail(request, slug):
    project = get_object_or_404(Project, slug=slug)
    
    return render_to_response('integration/project.html',
        { 'project': project }, context_instance=RequestContext(request) )

def build_detail(request, slug, id):
    run = get_object_or_404(BuildRun, id=id)
    length = run.end_time - run.start_time
    
    hours, remainder = divmod(length.seconds, 3600)
    minutes, seconds = divmod(remainder, 60)
    
    return render_to_response('integration/build.html',
        { 'run': run, 'hours': hours, 'minutes': minutes, 'seconds': seconds },
        context_instance=RequestContext(request) )

def run_build(request, slug):
    project = get_object_or_404(Project, slug=slug)
    
    if 'run' in request.POST and request.POST['run'] == 'run':
        project.run_build()
    
    return HttpResponseRedirect(project.get_absolute_url())