Fix silent crasher when reordering table rows
This commit is contained in:
parent
d169f131a2
commit
4fe3829b98
2 changed files with 7 additions and 7 deletions
|
@ -25,7 +25,7 @@
|
|||
<form action="" name="show_tasks" method="post">
|
||||
{% csrf_token %}
|
||||
<table class="table" id="tasktable">
|
||||
<tr>
|
||||
<tr class="nodrop">
|
||||
<th>Done</th>
|
||||
<th>Task</th>
|
||||
<th>Created</th>
|
||||
|
@ -93,8 +93,8 @@
|
|||
<script type="text/javascript">
|
||||
function order_tasks(data) {
|
||||
// The JQuery plugin tableDnD provides a serialize() function which provides the re-ordered
|
||||
// data in a list. We pass that list as an object called "data" to a Django view
|
||||
// to save the re-ordered data into the database.
|
||||
// data in a list. We pass that list as an object ("data") to a Django view
|
||||
// to save new priorities on each task in the list.
|
||||
$.post("{% url 'todo:reorder_tasks' %}", data, "json");
|
||||
return false;
|
||||
};
|
||||
|
|
|
@ -260,10 +260,10 @@ def reorder_tasks(request) -> HttpResponse:
|
|||
|
||||
# Re-prioritize each task in list
|
||||
i = 1
|
||||
for t in newtasklist:
|
||||
newtask = Task.objects.get(pk=t)
|
||||
newtask.priority = i
|
||||
newtask.save()
|
||||
for id in newtasklist:
|
||||
task = Task.objects.get(pk=id)
|
||||
task.priority = i
|
||||
task.save()
|
||||
i += 1
|
||||
|
||||
# All views must return an httpresponse of some kind ... without this we get
|
||||
|
|
Loading…
Reference in a new issue