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 <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2013-02-14 07:33:00 +00:00
parent eebbcf66c1
commit f5e37e18c0
2 changed files with 3 additions and 4 deletions

2
TODO
View File

@ -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

View File

@ -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):