Mercurial > public > sg101
comparison gpp/downloads/views.py @ 208:2022c0409296
Fix #76; use POST to get downloads to avoid having side-effects (updating hit count) on GETs.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 05 May 2010 03:12:15 +0000 |
parents | b4305e18d3af |
children | 27bee3ac85e6 |
comparison
equal
deleted
inserted
replaced
207:8bbefaa3e408 | 208:2022c0409296 |
---|---|
113 context_instance = RequestContext(request)) | 113 context_instance = RequestContext(request)) |
114 | 114 |
115 ####################################################################### | 115 ####################################################################### |
116 | 116 |
117 @login_required | 117 @login_required |
118 @require_POST | |
118 def download(request, id): | 119 def download(request, id): |
119 download = Download.public_objects.get(pk=id) | 120 download = Download.public_objects.get(pk=id) |
120 if download is None: | 121 if download is None: |
121 raise Http404 | 122 raise Http404 |
122 return _redirect_download(download) | 123 return _redirect_download(download) |
141 context_instance = RequestContext(request)) | 142 context_instance = RequestContext(request)) |
142 | 143 |
143 ####################################################################### | 144 ####################################################################### |
144 | 145 |
145 @login_required | 146 @login_required |
147 @require_POST | |
146 def random_download(request): | 148 def random_download(request): |
147 ids = Download.public_objects.values_list('id', flat=True) | 149 ids = Download.public_objects.values_list('id', flat=True) |
148 if not ids: | 150 if not ids: |
149 raise Http404 | 151 raise Http404 |
150 id = random.choice(ids) | 152 id = random.choice(ids) |