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