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 """