tinpan / integration / views.py

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 if run.end_time else None
    hours, remainder = divmod(length.seconds, 3600) if length else (None, None)
    minutes, seconds = divmod(remainder, 60) if length else (None, None)
    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':
    return HttpResponseRedirect(project.get_absolute_url())
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.