Prevent occasional crash during task re-ordering
Prevent occasional crash during task re-ordering
This commit is contained in:
parent
f6d79879ae
commit
184084c6a8
1 changed files with 9 additions and 4 deletions
|
@ -20,10 +20,15 @@ def reorder_tasks(request) -> HttpResponse:
|
|||
# Re-prioritize each task in list
|
||||
i = 1
|
||||
for id in newtasklist:
|
||||
try:
|
||||
task = Task.objects.get(pk=id)
|
||||
task.priority = i
|
||||
task.save()
|
||||
i += 1
|
||||
except Task.DoesNotExist:
|
||||
# Can occur if task is deleted behind the scenes during re-ordering.
|
||||
# Not easy to remove it from the UI without page refresh, but prevent crash.
|
||||
pass
|
||||
|
||||
# All views must return an httpresponse of some kind ... without this we get
|
||||
# error 500s in the log even though things look peachy in the browser.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue