From 209f118de2be448b3dbe1e105379f833731df95a Mon Sep 17 00:00:00 2001 From: Grizzly Date: Tue, 6 Aug 2019 07:41:27 +0000 Subject: [PATCH] =?UTF-8?q?R=C3=A9solution=20et=20r=C3=A9ouverture=20des?= =?UTF-8?q?=20tickets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tickets/forms.py | 7 +++++++ tickets/templates/tickets/aff_ticket.html | 18 ++++++++++-------- tickets/views.py | 7 ++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tickets/forms.py b/tickets/forms.py index 1b4fa4ce..4bb59458 100644 --- a/tickets/forms.py +++ b/tickets/forms.py @@ -28,3 +28,10 @@ class EditPreferencesForm(ModelForm): class Meta: model = Preferences fields = '__all__' + +class ChangeStatusTicketForm(ModelForm): + """ Passe un Ticket en résolu """ + class Meta: + model = Ticket + fields = [] + diff --git a/tickets/templates/tickets/aff_ticket.html b/tickets/templates/tickets/aff_ticket.html index 4683f1fc..f56a6b6c 100644 --- a/tickets/templates/tickets/aff_ticket.html +++ b/tickets/templates/tickets/aff_ticket.html @@ -54,14 +54,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,

{% trans "Description" %} {{ ticket.description }}

-{% if not ticket.solved %} - - {% trans "Mark as Solved" %} -{% else %} - - {% trans "Mark as Not Solved" %} -{% endif %} - +
+ {% csrf_token %} + {% bootstrap_form changestatusform %} + + {% if not ticket.solved %} + {% bootstrap_button "Résoudre" button_type="submit" button_class='btn-info' %} + {% else %} + {% bootstrap_button "Ouvrir" button_type="submit" button_class='btn-warning' %} + {% endif %} +
diff --git a/tickets/views.py b/tickets/views.py index 13b6ad23..0e89218d 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -12,6 +12,7 @@ from .models import( from .forms import ( NewTicketForm, + ChangeStatusTicketForm, EditPreferencesForm, ) @@ -47,7 +48,11 @@ def new_ticket(request): def aff_ticket(request,ticketid): """Vue d'affichage d'un ticket""" ticket = Ticket.objects.filter(id=ticketid).get() - return render(request,'tickets/aff_ticket.html',{'ticket':ticket}) + changestatusform = ChangeStatusTicketForm(request.POST) + if request.method == 'POST': + ticket.solved = not ticket.solved + ticket.save() + return render(request,'tickets/aff_ticket.html',{'ticket':ticket,'changestatusform':changestatusform}) def aff_tickets(request): """ Vue d'affichage de tout les tickets """