aboutsummaryrefslogtreecommitdiff
path: root/djangopypi/views/channel.py
diff options
context:
space:
mode:
Diffstat (limited to 'djangopypi/views/channel.py')
-rw-r--r--djangopypi/views/channel.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/djangopypi/views/channel.py b/djangopypi/views/channel.py
new file mode 100644
index 0000000..3dd7946
--- /dev/null
+++ b/djangopypi/views/channel.py
@@ -0,0 +1,48 @@
1from django.http import Http404
2from django.shortcuts import render_to_response
3from django.template import RequestContext
4
5from djangopypi.models import Project, Release, Channel
6
7
8def list_channels(request, template_name="djangopypi/simple.html"):
9 channels = Channel.objects.all().order_by("name")
10 context = RequestContext(request, { "dists": channels })
11 return render_to_response(template_name, context_instance=context)
12
13
14def show_links(request, channel, dist_name,
15 template_name="djangopypi/show_links.html"):
16 try:
17 project = Project.objects.get(name=dist_name)
18 releases = (Release.objects
19 .filter(project__name=dist_name, channel__name=channel)
20 .order_by('-version'))
21 except Project.DoesNotExist:
22 raise Http404
23
24 context = RequestContext(request, {
25 "dist_name": dist_name,
26 "releases": releases,
27 })
28
29 return render_to_response(template_name, context_instance=context)
30
31
32def show_channel(request, channel,
33 template_name="djangopypi/show_channel.html"):
34 try:
35 projects = (Project.objects
36 .filter(releases__channel__name=channel)
37 .distinct().all().order_by('name'))
38
39 channel = Channel.objects.get(name=channel)
40 except Project.DoesNotExist:
41 raise Http404
42
43 context = RequestContext(request, {
44 "projects": projects,
45 "channel": channel,
46 })
47
48 return render_to_response(template_name, context_instance=context)