From a025708ef9f4f32daab29ca96b3fbec49a7b05dd Mon Sep 17 00:00:00 2001 From: Dusty Phillips Date: Mon, 4 May 2009 20:24:41 -0400 Subject: Fix a bug when someone accesses the update page without POSTINg adopt or disown. Probably occurred by a press of the back button. --- packages/views.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/views.py b/packages/views.py index 49ab9a0..835323f 100644 --- a/packages/views.py +++ b/packages/views.py @@ -15,6 +15,7 @@ from archweb_dev.main.utils import make_choice def update(request): ids = request.POST.getlist('pkgid') + mode = None if request.POST.has_key('adopt'): mode = 'adopt' maint_id = request.user.id @@ -22,13 +23,16 @@ def update(request): mode = 'disown' maint_id = 0 - for id in ids: - pkg = Package.objects.get(id=id) - pkg.maintainer_id = maint_id - pkg.save() + if mode: + for id in ids: + pkg = Package.objects.get(id=id) + pkg.maintainer_id = maint_id + pkg.save() - request.user.message_set.create(message="%d packages %sed" % ( - len(ids), mode)) + request.user.message_set.create(message="%d packages %sed" % ( + len(ids), mode)) + else: + request.user.message_set.create(message="update called without adopt/disown") return HttpResponseRedirect('/packages/') def details(request, name='', repo='', arch=''): -- cgit v1.2.3-24-g4f1b