aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-05-27 01:14:08 -0400
committerMike Crute <mcrute@gmail.com>2010-05-27 01:14:08 -0400
commit5a68ee32fe6ec7a381a16245f85fde210500dfd7 (patch)
tree8bdac814a7ff66f0c3aa297a6d3c1f3df191d4db
parent93481083e6fa15490584e61a3f6a5638024f9b31 (diff)
downloadchishop-5a68ee32fe6ec7a381a16245f85fde210500dfd7.tar.bz2
chishop-5a68ee32fe6ec7a381a16245f85fde210500dfd7.tar.xz
chishop-5a68ee32fe6ec7a381a16245f85fde210500dfd7.zip
Adding channel support
-rw-r--r--chishop/templates/djangopypi/pypi_show_links.html3
-rw-r--r--chishop/templates/djangopypi/show_channel.html7
-rw-r--r--djangopypi/admin.py10
-rw-r--r--djangopypi/models.py19
-rw-r--r--djangopypi/urls/__init__.py1
-rw-r--r--djangopypi/urls/channel.py12
-rw-r--r--djangopypi/views/channel.py48
7 files changed, 97 insertions, 3 deletions
diff --git a/chishop/templates/djangopypi/pypi_show_links.html b/chishop/templates/djangopypi/pypi_show_links.html
index 6e46635..13fc2e5 100644
--- a/chishop/templates/djangopypi/pypi_show_links.html
+++ b/chishop/templates/djangopypi/pypi_show_links.html
@@ -8,7 +8,7 @@
8{{ project.description|saferst }} 8{{ project.description|saferst }}
9 9
10<br/> 10<br/>
11<table><thead><th>Filename</th><th>Platform</th><th>Type</th><th>Version</th><th>Uploaded On</th><th>Size</th></thead> 11<table><thead><th>Filename</th><th>Platform</th><th>Type</th><th>Version</th><th>Uploaded On</th><th>Size</th><th>Channel</th></thead>
12<tbody> 12<tbody>
13 {% for release in releases %} 13 {% for release in releases %}
14 <tr> 14 <tr>
@@ -18,6 +18,7 @@
18 <td>{{ release.version }}</td> 18 <td>{{ release.version }}</td>
19 <td>{{ release.upload_time }}</td> 19 <td>{{ release.upload_time }}</td>
20 <td>{{ release.distribution.size|filesizeformat }}</td> 20 <td>{{ release.distribution.size|filesizeformat }}</td>
21 <td>{{ release.channel }}</td>
21 </tr> 22 </tr>
22 {% endfor %} 23 {% endfor %}
23</tbody></table> 24</tbody></table>
diff --git a/chishop/templates/djangopypi/show_channel.html b/chishop/templates/djangopypi/show_channel.html
new file mode 100644
index 0000000..86d312c
--- /dev/null
+++ b/chishop/templates/djangopypi/show_channel.html
@@ -0,0 +1,7 @@
1<html><head><title>Links for {{ channel.name }}</title></head><body>
2<h1>Links for {{ channel.name }}</h1>
3
4{% for project in projects %}
5<a href="{{ project.name }}">{{ project.name }}</a><br />
6{% endfor %}
7</body></html>
diff --git a/djangopypi/admin.py b/djangopypi/admin.py
index 6f994e8..663cc8e 100644
--- a/djangopypi/admin.py
+++ b/djangopypi/admin.py
@@ -1,6 +1,12 @@
1from django.contrib import admin 1from django.contrib import admin
2from djangopypi.models import Project, Release, Classifier 2from djangopypi.models import Project, Release, Classifier, Channel
3
4
5class ReleaseAdmin(admin.ModelAdmin):
6 list_display = ['release_name', 'channel']
7
3 8
4admin.site.register(Project) 9admin.site.register(Project)
5admin.site.register(Release) 10admin.site.register(Channel)
6admin.site.register(Classifier) 11admin.site.register(Classifier)
12admin.site.register(Release, ReleaseAdmin)
diff --git a/djangopypi/models.py b/djangopypi/models.py
index d98c4da..3539fb2 100644
--- a/djangopypi/models.py
+++ b/djangopypi/models.py
@@ -35,6 +35,22 @@ ARCHITECTURES = (
35UPLOAD_TO = getattr(settings, 35UPLOAD_TO = getattr(settings,
36 "DJANGOPYPI_RELEASE_UPLOAD_TO", 'dist') 36 "DJANGOPYPI_RELEASE_UPLOAD_TO", 'dist')
37 37
38
39class Channel(models.Model):
40 name = models.CharField(max_length=255, unique=True)
41
42 class Meta:
43 verbose_name = _(u"channel")
44 verbose_name_plural = _(u"channels")
45
46 def __unicode__(self):
47 return self.name
48
49 @models.permalink
50 def get_absolute_url(self):
51 return ('djangopypi-channel_show_dists', (), {'channel': self.name})
52
53
38class Classifier(models.Model): 54class Classifier(models.Model):
39 name = models.CharField(max_length=255, unique=True) 55 name = models.CharField(max_length=255, unique=True)
40 56
@@ -82,6 +98,7 @@ class Project(models.Model):
82 except Release.DoesNotExist: 98 except Release.DoesNotExist:
83 return None 99 return None
84 100
101
85class Release(models.Model): 102class Release(models.Model):
86 version = models.CharField(max_length=32) 103 version = models.CharField(max_length=32)
87 distribution = models.FileField(upload_to=UPLOAD_TO) 104 distribution = models.FileField(upload_to=UPLOAD_TO)
@@ -92,6 +109,8 @@ class Release(models.Model):
92 pyversion = models.CharField(max_length=32, blank=True) 109 pyversion = models.CharField(max_length=32, blank=True)
93 project = models.ForeignKey(Project, related_name="releases") 110 project = models.ForeignKey(Project, related_name="releases")
94 upload_time = models.DateTimeField(auto_now=True) 111 upload_time = models.DateTimeField(auto_now=True)
112 channel = models.ForeignKey(Channel, related_name="channels",
113 blank=True, null=True)
95 114
96 class Meta: 115 class Meta:
97 verbose_name = _(u"release") 116 verbose_name = _(u"release")
diff --git a/djangopypi/urls/__init__.py b/djangopypi/urls/__init__.py
index e362edc..50fd02b 100644
--- a/djangopypi/urls/__init__.py
+++ b/djangopypi/urls/__init__.py
@@ -3,6 +3,7 @@ from django.conf.urls.defaults import patterns, include
3 3
4urlpatterns = patterns('djangopypi.views', 4urlpatterns = patterns('djangopypi.views',
5 (r'^simple/', include('djangopypi.urls.simple')), 5 (r'^simple/', include('djangopypi.urls.simple')),
6 (r'^channel/', include('djangopypi.urls.channel')),
6 7
7 (r'^$', 'simple', {'template_name': 'djangopypi/pypi.html'}, 8 (r'^$', 'simple', {'template_name': 'djangopypi/pypi.html'},
8 'djangopypi-pypi'), 9 'djangopypi-pypi'),
diff --git a/djangopypi/urls/channel.py b/djangopypi/urls/channel.py
new file mode 100644
index 0000000..2bb19a8
--- /dev/null
+++ b/djangopypi/urls/channel.py
@@ -0,0 +1,12 @@
1# -*- coding: utf-8 -*-
2from django.conf.urls.defaults import patterns
3
4urlpatterns = patterns('djangopypi.views.channel',
5 (r'^$', 'list_channels', {}, 'djangopypi-channel_simple'),
6
7 (r'^(?P<channel>[\w\d_\.\-]+)/$',
8 'show_channel', {}, 'djangopypi-channel_show_dists'),
9
10 (r'^(?P<channel>[\w\d_\.\-]+)/(?P<dist_name>[\w\d_\.\-]+)/$',
11 'show_links', {}, 'djangopypi-channel_show_links'),
12)
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)