diff options
Diffstat (limited to 'patchtracker/views.py')
-rw-r--r-- | patchtracker/views.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/patchtracker/views.py b/patchtracker/views.py new file mode 100644 index 0000000..0a316eb --- /dev/null +++ b/patchtracker/views.py @@ -0,0 +1,75 @@ +import os + +import django.db.models +import django.http +import django.shortcuts +import django.template + +import ComplexQueries +import Conf +import models + +def package_vers(request, package, version): + pkg = models.SourcePackage.objects.get( name=package, version=version ) + ctx = django.template.RequestContext(request) + tmpl = 'package_vers.html' + extra = { 'pkg':pkg, 'ctx':ctx, 'conf':Conf } + return django.shortcuts.render_to_response(tmpl, extra, context_instance=ctx) + +def display_toc(request, index): + packageIndex = ComplexQueries.PackageIndex(index) + tmpl = 'searchresults.html' + searchDescription = "Packages by index" + extra = { 'index':index, 'packageIndex':packageIndex, 'conf':Conf, + 'searchDescription':searchDescription, 'searchKey':index } + return django.shortcuts.render_to_response(tmpl, extra) + +def maintainer_search(request, maintainer): + mappings = models.SourcePackageMapping.objects.order_by('package__name').filter( django.db.models.Q(package__maintainer__contains=maintainer) | django.db.models.Q(package__uploaders__contains=maintainer ) ) + packageIndex = ComplexQueries.PackageIndexQuery( mappings ) + tmpl = 'searchresults.html' + searchDescription = "Maintainer email" + extra = { 'index':maintainer, 'packageIndex':packageIndex, 'conf':Conf, + 'searchDescription':searchDescription, 'searchKey':maintainer } + return django.shortcuts.render_to_response(tmpl, extra) + +def display_patch(request, patchType, package, version, patchName): + pkg = models.SourcePackage.objects.get( name=package, version=version ) + ctx = django.template.RequestContext(request) + tmpl = 'patch_view.html' + + if patchType == "debianonly": + patch = pkg.diffhandler().debiandir() + patchTitle = "debian-dir only changes" + elif patchType == "misc": + patch = pkg.diffhandler().filterdiff(include=patchName) + patchTitle = patchName + elif patchType == "nondebian": + patch = pkg.diffhandler().nondebiandir() + patchTitle = "direct (non-packaging) changes" + elif patchType == "series": + patch = pkg.diffhandler().series().fetch(patchName) + patchTitle = patchName + + extra = { 'pkg':pkg, 'patch':patch, 'patchType':patchType, 'conf':Conf, + 'patchName':patchName, 'patchTitle':patchTitle } + return django.shortcuts.render_to_response(tmpl, extra, context_instance=ctx) + +def download_patch(request, patchType, package, version, patchName): + pkg = models.SourcePackage.objects.get( name=package, version=version ) + if patchType == "debianonly": + patch = pkg.diffhandler().debiandir() + elif patchType == "misc": + patch = pkg.diffhandler().filterdiff(include=patchName) + elif patchType == "nondebian": + patch = pkg.diffhandler().nondebiandir() + elif patchType == "series": + patch = pkg.diffhandler().series().fetch(patchName) + return django.http.HttpResponse(patch, mimetype="text/plain") + +def frontpage(request): + nonlibs = [idx for idx in models.SourcePackage.objects.filter(~django.db.models.Q(name__startswith='lib')).extra(select={'index' : "SUBSTR(name, 1, 1)"}).distinct().values_list('index', flat=True)] + libs = [idx for idx in models.SourcePackage.objects.filter(name__startswith='lib').extra(select={'index' : "SUBSTR(name, 1, 4)"}).distinct().values_list('index', flat=True)] + indices = sorted(nonlibs + libs) + extra = { 'indices':indices, 'conf':Conf } + return django.shortcuts.render_to_response('frontpage.html', extra) |