diff options
author | Dan McGee <dan@archlinux.org> | 2013-01-19 17:38:54 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2013-01-19 17:40:26 -0600 |
commit | b642c93aff6bd22013615ae8b51b7a02763e261c (patch) | |
tree | 97155528ace995c55bda91fdaa39fc316c729e16 /releng/views.py | |
parent | 4d52242f4b5a20a591b5bd44cc0dc12f15a9c92c (diff) |
Add a view to download the torrent available for a given release
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'releng/views.py')
-rw-r--r-- | releng/views.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/releng/views.py b/releng/views.py index 6c49275f..ad4b07d1 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: |