summaryrefslogtreecommitdiff
path: root/patchtracker/views.py
blob: e790f3ab88d169186f50ab38fb8342fb65a83057 (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
import os

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 = 'letter_toc.html'
  extra = { 'index':index, 'packageIndex':packageIndex, 'conf':Conf }
  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")