From f5e37e18c0aceb357af45d09581ca7484fb09178 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 14 Feb 2013 07:33:00 +0000 Subject: [PATCH] Ensure publishing a layer already published does nothing Just in case two users go to publish the same layer at around the same time, avoid saving the record for a user who tries to publishes it after the first time. Signed-off-by: Paul Eggleton --- TODO | 2 -- layerindex/views.py | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 1d6d4d3..63919c2 100644 --- a/TODO +++ b/TODO @@ -6,8 +6,6 @@ TODO: - we might consider adding a link to the all layers and all recipes tables from the layer details page -* Ensure publishing a published layer doesn't do anything - * Need an "About" section descriptibing what the site is for * Need an admin contact in footer * Some columns are a bit crushed diff --git a/layerindex/views.py b/layerindex/views.py index 374e144..a96ec40 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -77,8 +77,9 @@ def publish(request, name): def _statuschange(request, name, newstatus): w = get_object_or_404(LayerItem, name=name) - w.change_status(newstatus, request.user.username) - w.save() + if w.status != newstatus: + w.change_status(newstatus, request.user.username) + w.save() return HttpResponseRedirect(reverse('layer_item', args=(name,))) class LayerListView(ListView):