[chronojump-server] Added a class to delete tasks
- From: Max Ros i Morejon <maxros src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Added a class to delete tasks
- Date: Sun, 25 Nov 2018 19:28:40 +0000 (UTC)
commit f11d92e01d1f77a3c1a609336a37e8f49fc047cc
Author: Max Ros i Morejon <mros33 gmail com>
Date: Sun Nov 25 20:03:00 2018 +0100
Added a class to delete tasks
.../chronojump_networks/tasks/api/views.py | 6 +++++-
.../organizations/groups/group_players_list.html | 22 ++++++++++++++++++----
2 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/chronojumpserver-django/chronojump_networks/tasks/api/views.py
b/chronojumpserver-django/chronojump_networks/tasks/api/views.py
index 700ca2f..c851e97 100644
--- a/chronojumpserver-django/chronojump_networks/tasks/api/views.py
+++ b/chronojumpserver-django/chronojump_networks/tasks/api/views.py
@@ -79,5 +79,9 @@ class TaskRetrieveUpdateDestroyAPIView(RetrieveUpdateDestroyAPIView):
o.lossByPower = int(data['lossByPower'][0])
o.comment = data['comment'][0]
o.save()
-
return JsonResponse({}, status=200, safe=False)
+
+ def destroy(self, request, *args, **kwars):
+ o = get_object_or_404(Task, id=self.kwargs['task_id'])
+ o.delete()
+ return JsonResponse({}, status=204, safe=False)
diff --git
a/chronojumpserver-django/chronojump_networks/templates/organizations/groups/group_players_list.html
b/chronojumpserver-django/chronojump_networks/templates/organizations/groups/group_players_list.html
index fa633a0..04dad55 100644
--- a/chronojumpserver-django/chronojump_networks/templates/organizations/groups/group_players_list.html
+++ b/chronojumpserver-django/chronojump_networks/templates/organizations/groups/group_players_list.html
@@ -259,11 +259,11 @@
html += 'data-task-type="' + task.type + '">'
html += '<i class="material-icons">mode_edit</i></a>';
html += ' ';
- html += '<a class="task-link task-duplicate-link" data-toogle="tooltip" data-placement="right"
title="' + "{% trans 'Duplicate this task' %}" +'"';
+ /*html += '<a class="task-link task-duplicate-link" data-toogle="tooltip" data-placement="right"
title="' + "{% trans 'Duplicate this task' %}" +'"';
html += 'data-task-id="' + task.id + '"'
html += 'data-task-type="' + task.type + '">'
html += '<i class="material-icons">content_copy</i></a>';
- html += ' ';
+ html += ' ';*/
html += '<a class="task-link task-delete-link" data-toogle="tooltip" data-placement="right"
title="' + "{% trans 'Delete this task' %}" +'"';
html += 'data-task-id="' + task.id + '"'
html += 'data-task-type="' + task.type + '">'
@@ -336,8 +336,22 @@
console.log("Clicant duplicar botó");
});
- $('.task-delete-link').on('click', function() {
- console.log("Clicant esborrar botó");
+ $('.task-delete-link').on('click', function() {
+ //TODO: Ask for confirmation
+ console.log("Clicant esborrar botó");
+ var task_id = $(this).attr('data-task-id');
+ var task_url = "{% url 'api_tasks:task_detail' task_id=0 %}".replace("0", task_id)
+
+ $.ajax({
+ url: task_url,
+ method: 'DELETE',
+ success: function(task) {
+ alert("{% trans 'The task has been deleted' %}");
+ table_players.ajax.reload(enablePlayersTableFunctionality, false);
+ }
+ });
+
+
});
} );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]