Mercurial > public > sg101
comparison gpp/weblinks/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 | 7e8d2dda99e3 |
comparison
equal
deleted
inserted
replaced
207:8bbefaa3e408 | 208:2022c0409296 |
---|---|
138 link.save() | 138 link.save() |
139 return HttpResponseRedirect(link.url) | 139 return HttpResponseRedirect(link.url) |
140 | 140 |
141 ####################################################################### | 141 ####################################################################### |
142 | 142 |
143 @require_POST | |
143 def visit(request, link_id): | 144 def visit(request, link_id): |
144 link = get_object_or_404(Link, pk = link_id) | 145 link = get_object_or_404(Link, pk = link_id) |
145 return _visit_link(request, link) | 146 return _visit_link(request, link) |
146 | 147 |
147 ####################################################################### | 148 ####################################################################### |
148 | 149 |
150 @require_POST | |
149 def random_link(request): | 151 def random_link(request): |
150 ids = Link.public_objects.values_list('id', flat=True) | 152 ids = Link.public_objects.values_list('id', flat=True) |
151 if not ids: | 153 if not ids: |
152 raise Http404 | 154 raise Http404 |
153 id = random.choice(ids) | 155 id = random.choice(ids) |