diff options
-rw-r--r-- | releng/urls.py | 15 | ||||
-rw-r--r-- | releng/views.py | 16 |
2 files changed, 26 insertions, 5 deletions
diff --git a/releng/urls.py b/releng/urls.py index 8413d31..76c3634 100644 --- a/releng/urls.py +++ b/releng/urls.py @@ -11,11 +11,18 @@ feedback_patterns = patterns('releng.views', (r'^iso/overview/$', 'iso_overview', {}, 'releng-iso-overview'), ) -urlpatterns = patterns('', - (r'^feedback/', include(feedback_patterns)), - (r'^releases/$', +releases_patterns = patterns('releng.views', + (r'^$', ReleaseListView.as_view(), {}, 'releng-release-list'), - (r'^releases/(?P<version>[-.\w]+)/$', + (r'^(?P<version>[-.\w]+)/$', ReleaseDetailView.as_view(), {}, 'releng-release-detail'), + (r'^(?P<version>[-.\w]+)/torrent/$', + 'release_torrent', {}, 'releng-release-torrent'), ) + +urlpatterns = patterns('', + (r'^feedback/', include(feedback_patterns)), + (r'^releases/', include(releases_patterns)), +) + # vim: set ts=4 sw=4 et: diff --git a/releng/views.py b/releng/views.py index 6c49275..ad4b07d 100644 --- a/releng/views.py +++ b/releng/views.py @@ -1,7 +1,9 @@ +from base64 import b64decode + from django import forms from django.conf import settings from django.db.models import Count, Max -from django.http import Http404 +from django.http import Http404, HttpResponse from django.shortcuts import get_object_or_404, redirect, render from django.views.generic import DetailView, ListView @@ -224,4 +226,16 @@ class ReleaseDetailView(DetailView): slug_field = 'version' slug_url_kwarg = 'version' + +def release_torrent(request, version): + release = get_object_or_404(Release, version=version) + if not release.torrent_data: + raise Http404 + data = b64decode(release.torrent_data) + response = HttpResponse(data, content_type='application/x-bittorrent') + # TODO: this is duplicated from Release.iso_url() + filename = 'archlinux-%s-dual.iso.torrent' % release.version + response['Content-Disposition'] = 'attachment; filename=%s' % filename + return response + # vim: set ts=4 sw=4 et: |