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
|
from django.http import Http404
from django.shortcuts import render_to_response
from django.template import RequestContext
from djangopypi.models import Project, Release, Channel
def list_channels(request, template_name="djangopypi/simple.html"):
channels = Channel.objects.all().order_by("name")
context = RequestContext(request, { "dists": channels })
return render_to_response(template_name, context_instance=context)
def show_links(request, channel, dist_name,
template_name="djangopypi/show_links.html"):
try:
project = Project.objects.get(name=dist_name)
releases = (Release.objects
.filter(project__name=dist_name, channel__name=channel)
.order_by('-version'))
except Project.DoesNotExist:
raise Http404
context = RequestContext(request, {
"dist_name": dist_name,
"releases": releases,
})
return render_to_response(template_name, context_instance=context)
def show_channel(request, channel,
template_name="djangopypi/show_channel.html"):
try:
projects = (Project.objects
.filter(releases__channel__name=channel)
.distinct().all().order_by('name'))
channel = Channel.objects.get(name=channel)
except Project.DoesNotExist:
raise Http404
context = RequestContext(request, {
"projects": projects,
"channel": channel,
})
return render_to_response(template_name, context_instance=context)
|