summaryrefslogtreecommitdiff
path: root/patchtracker/views.py
blob: 0a316eb07959d7175b03598fc11273e7e2e065bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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)