8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

Fix and harmonize some issues in ticket app

This commit is contained in:
Gabriel Detraz 2020-04-22 21:37:21 +02:00
parent acf510a8e7
commit c8c89fab1d
16 changed files with 216 additions and 237 deletions

View file

@ -25,6 +25,7 @@ Ticket form
from django import forms
from django.template.loader import render_to_string
from django.forms import ModelForm, Form
from re2o.field_permissions import FieldPermissionFormMixin
from re2o.mixins import FormRevMixin
@ -33,19 +34,31 @@ from django.utils.translation import ugettext_lazy as _
from .models import Ticket
class NewTicketForm(ModelForm):
class NewTicketForm(FormRevMixin, ModelForm):
""" Creation of a ticket"""
email = forms.EmailField(required=False)
class Meta:
model = Ticket
fields = ["title", "description", "email"]
def __init__(self, *args, **kwargs):
request = kwargs.pop("request")
super(NewTicketForm, self).__init__(*args, **kwargs)
if request.user.is_authenticated:
self.fields.pop('email')
self.instance.user = request.user
self.fields['description'].help_text = render_to_string('tickets/help_text.html')
self.instance.request = request
class ChangeStatusTicketForm(ModelForm):
""" Change ticket status"""
class EditTicketForm(FormRevMixin, ModelForm):
""" Creation of a ticket"""
class Meta:
model = Ticket
fields = []
fields = "__all__"
def __init__(self, *args, **kwargs):
super(EditTicketForm, self).__init__(*args, **kwargs)
self.fields['email'].required = False

View file

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 2.5\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-22 19:00+0200\n"
"POT-Creation-Date: 2020-04-22 22:06+0200\n"
"PO-Revision-Date: 2019-11-16 00:35+0100\n"
"Last-Translator: Laouen Fernet <laouen.fernet@supelec.fr>\n"
"Language-Team: \n"
@ -34,32 +34,28 @@ msgstr ""
msgid "Title of the ticket."
msgstr "Titre du ticket."
#: tickets/models.py:58
msgid "Description of the ticket."
msgstr "Description du ticket."
#: tickets/models.py:64
#: tickets/models.py:63
msgid "An email address to get back to you."
msgstr "Une adresse mail pour vous recontacter."
#: tickets/models.py:70
#: tickets/models.py:69
msgid "Can view a ticket object"
msgstr "Peut voir un objet ticket"
#: tickets/models.py:71
#: tickets/models.py:70
msgid "ticket"
msgstr "ticket"
#: tickets/models.py:72
#: tickets/models.py:71
msgid "tickets"
msgstr "tickets"
#: tickets/models.py:76
#: tickets/models.py:75
#, python-format
msgid "Ticket from %(name)s. Date: %(date)s."
msgstr "Ticket de %(name)s. Date : %(date)s."
#: tickets/models.py:78
#: tickets/models.py:77
#, python-format
msgid "Anonymous ticket. Date: %s."
msgstr "Ticket anonyme. Date : %s."
@ -76,34 +72,22 @@ msgstr "Vous n'avez pas le droit de voir la liste des tickets."
msgid "Publish address"
msgstr "Adresse mail de publication"
#: tickets/preferences/forms.py:45
msgid "Mail language"
msgstr "Langue du mail"
#: tickets/preferences/models.py:38
#: tickets/preferences/models.py:39
msgid ""
"Email address to publish the new tickets (leave empty for no publication)."
msgstr ""
"Adresse mail où publier les nouveaux tickets (laissez vide pour ne pas "
"publier)."
#: tickets/preferences/models.py:45
msgid "French"
msgstr "Français"
#: tickets/preferences/models.py:45
msgid "English"
msgstr "Anglais"
#: tickets/preferences/models.py:49
#: tickets/preferences/models.py:46
msgid "tickets options"
msgstr "Options des tickets"
#: tickets/preferences/models.py:50
#: tickets/preferences/models.py:47
msgid "Can view tickets options"
msgstr "Peut voir les options des tickets"
#: tickets/templates/tickets/aff_ticket.html:30
#: tickets/templates/tickets/aff_ticket.html:31
#: tickets/templates/tickets/contact.html:4
#: tickets/templates/tickets/index.html:29
#: tickets/templates/tickets/preferences.html:6
@ -111,59 +95,62 @@ msgstr "Peut voir les options des tickets"
msgid "Tickets"
msgstr "Tickets"
#: tickets/templates/tickets/aff_ticket.html:34
#: tickets/templates/tickets/aff_ticket.html:35
#, python-format
msgid "Ticket #%(id)s"
msgstr "Ticket #%(id)s"
#: tickets/templates/tickets/aff_ticket.html:36
#: tickets/templates/tickets/aff_ticket.html:37
#: tickets/templates/tickets/aff_tickets.html:58
msgid "Solved"
msgstr "Résolu"
#: tickets/templates/tickets/aff_ticket.html:38
#: tickets/templates/tickets/aff_ticket.html:39
msgid "Not solved"
msgstr "Non résolu"
#: tickets/templates/tickets/aff_ticket.html:44
#: tickets/templates/tickets/aff_ticket.html:45
msgid "Opened by"
msgstr "Ouvert par"
#: tickets/templates/tickets/aff_ticket.html:50
#: tickets/templates/tickets/aff_ticket.html:51
msgid "Anonymous user"
msgstr "Utilisateur anonyme"
#: tickets/templates/tickets/aff_ticket.html:54
#: tickets/templates/tickets/aff_ticket.html:55
msgid "Response address: "
msgstr "Adresse de réponse : "
#: tickets/templates/tickets/aff_ticket.html:54
#: tickets/templates/tickets/aff_ticket.html:55
msgid "Response to your ticket"
msgstr "Réponse à votre ticket"
#: tickets/templates/tickets/aff_ticket.html:59
#: tickets/templates/tickets/aff_ticket.html:60
msgid "Title:"
msgstr "Titre :"
#: tickets/templates/tickets/aff_ticket.html:60
#: tickets/templates/tickets/aff_ticket.html:61
msgid "Description:"
msgstr "Description :"
#: tickets/templates/tickets/aff_ticket.html:68
#: tickets/templates/tickets/aff_ticket.html:65
msgid "Edit this ticket"
msgstr "Modifier le ticket."
#: tickets/templates/tickets/aff_ticket.html:67
msgid "Mark as solved"
msgstr "Marquer comme résolu"
#: tickets/templates/tickets/aff_ticket.html:71
msgid "Mark as not solved"
#: tickets/templates/tickets/aff_ticket.html:69
msgid "Mark as unsolved"
msgstr "Marquer comme non résolu"
#: tickets/templates/tickets/aff_ticket.html:81
#: tickets/templates/tickets/aff_ticket.html:78
msgid "All tickets"
msgstr "Tous les tickets"
#: tickets/templates/tickets/aff_tickets.html:35
#: tickets/templates/tickets/form_preferences.html:30
#: tickets/templates/tickets/form_ticket.html:31
#: tickets/templates/tickets/edit.html:31
msgid "Ticket"
msgid_plural "Tickets"
msgstr[0] "Ticket"
@ -213,28 +200,11 @@ msgstr ""
msgid "Open a ticket"
msgstr "Ouvrir un ticket"
#: tickets/templates/tickets/form_preferences.html:33
msgid "Editing of tickets preferences"
msgstr "Modification des préférences de tickets"
#: tickets/templates/tickets/form_preferences.html:46
#: tickets/templates/tickets/preferences.html:14
msgid "Edit"
msgstr "Modifier"
#: tickets/templates/tickets/form_ticket.html:34
#: tickets/templates/tickets/edit.html:34
msgid "Ticket opening"
msgstr "Ouverture de ticket"
#: tickets/templates/tickets/form_ticket.html:39 tickets/views.py:85
msgid ""
"You are not authenticated. Please log in or provide an email address so we "
"can get back to you."
msgstr ""
"Vous n'êtes pas authentifié. Veuillez vous connecter ou fournir une adresse "
"mail pour que nous puissions vous recontacter."
#: tickets/templates/tickets/form_ticket.html:44
#: tickets/templates/tickets/help_text.html:3
msgid ""
"Description of your problem. Please give as much information as possible to "
"help us searching for a solution. Here is some information we might need:"
@ -243,11 +213,11 @@ msgstr ""
"possible pour nous aider à chercher une solution. Voici quelques "
"informations dont nous pourrions avoir besoin :"
#: tickets/templates/tickets/form_ticket.html:47
#: tickets/templates/tickets/help_text.html:6
msgid "The type of your problem (membership, connection, payment etc.)."
msgstr "Le type de votre problème (adhésion, connexion, paiement etc.)."
#: tickets/templates/tickets/form_ticket.html:50
#: tickets/templates/tickets/help_text.html:9
msgid ""
"The conditions in which you encounter the problem (Wi-Fi/wired connection, "
"on every machines or only one, on a new machine etc.)."
@ -256,7 +226,7 @@ msgstr ""
"filaire, sur toutes les machines ou une seule, sur une nouvelle machine "
"etc.)."
#: tickets/templates/tickets/form_ticket.html:53
#: tickets/templates/tickets/help_text.html:12
msgid ""
"The locations where you encounter the problem (in your room, in a common "
"space, in a specific building etc.)."
@ -264,10 +234,6 @@ msgstr ""
"Les lieux où vous rencontrez le problème (dans votre chambre, dans un espace "
"commun, dans un bâtiment en particulier etc.)."
#: tickets/templates/tickets/form_ticket.html:56
msgid "Open the ticket"
msgstr "Ouvrir le ticket"
#: tickets/templates/tickets/index.html:32
msgid "List of tickets"
msgstr "Liste des tickets"
@ -276,6 +242,10 @@ msgstr "Liste des tickets"
msgid "Manage the tickets"
msgstr "Gérer les tickets"
#: tickets/templates/tickets/preferences.html:14
msgid "Edit"
msgstr "Modifier"
#: tickets/templates/tickets/preferences.html:21
msgid "Publication email address"
msgstr "Adresse mail de publication"
@ -284,25 +254,56 @@ msgstr "Adresse mail de publication"
msgid "No email address, the tickets will not be published."
msgstr "Pas d'adresse mail, les tickets ne seront pas publiés."
#: tickets/templates/tickets/preferences.html:29
msgid "Email language"
msgstr "Langue du mail"
#: tickets/templates/tickets/profil.html:19
msgid "No tickets"
msgstr "Pas de tickets"
#: tickets/views.py:66 tickets/views.py:77
#: tickets/views.py:56
msgid ""
"Your ticket has been succesfully opened. We will take care of it as soon as "
"possible."
msgstr ""
"Votre ticket a bien été ouvert. Nous nous en occuperons dès que possible."
#: tickets/views.py:122 tickets/views.py:147
#: tickets/views.py:102
msgid "Ticket has been updated successfully"
msgstr "Le ticket a été mis à jour"
#: tickets/views.py:123 tickets/views.py:148
msgid "Never"
msgstr "Jamais"
#~ msgid "Description of the ticket."
#~ msgstr "Description du ticket."
#~ msgid "Mail language"
#~ msgstr "Langue du mail"
#~ msgid "French"
#~ msgstr "Français"
#~ msgid "English"
#~ msgstr "Anglais"
#~ msgid "Mark as not solved"
#~ msgstr "Marquer comme non résolu"
#~ msgid "Editing of tickets preferences"
#~ msgstr "Modification des préférences de tickets"
#~ msgid ""
#~ "You are not authenticated. Please log in or provide an email address so "
#~ "we can get back to you."
#~ msgstr ""
#~ "Vous n'êtes pas authentifié. Veuillez vous connecter ou fournir une "
#~ "adresse mail pour que nous puissions vous recontacter."
#~ msgid "Open the ticket"
#~ msgstr "Ouvrir le ticket"
#~ msgid "Email language"
#~ msgstr "Langue du mail"
#~ msgid "The tickets preferences were edited."
#~ msgstr "Les préférences de tickets ont été modifiées."

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.28 on 2020-04-22 19:27
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tickets', '0003_auto_20200422_1839'),
]
operations = [
migrations.RemoveField(
model_name='ticketoption',
name='mail_language',
),
migrations.AlterField(
model_name='ticket',
name='description',
field=models.TextField(max_length=3000),
),
]

View file

@ -31,7 +31,7 @@ from django.db.models.signals import post_save
from django.dispatch import receiver
from re2o.mixins import AclMixin
from re2o.mail_utils import send_mail
from django.core.mail import EmailMessage
from preferences.models import GeneralOption
@ -55,7 +55,6 @@ class Ticket(AclMixin, models.Model):
)
description = models.TextField(
max_length=3000,
help_text=_("Description of the ticket."),
blank=False,
null=False,
)
@ -77,27 +76,28 @@ class Ticket(AclMixin, models.Model):
else:
return _("Anonymous ticket. Date: %s.") % (self.date)
def publish_mail(self, request=None):
def publish_mail(self):
site_url = GeneralOption.get_cached_value("main_site_url")
to_addr = TicketOption.get_cached_value("publish_address")
context = {"ticket": self, "site_url": site_url}
lang = TicketOption.get_cached_value("mail_language")
if lang == 0:
language = getattr(self.request, "LANGUAGE_CODE", "en")
if language == "fr":
obj = "Nouveau ticket ouvert"
template = loader.get_template("tickets/publication_mail_fr")
else:
obj = "New ticket opened"
template = loader.get_template("tickets/publication_mail_en")
send_mail(
request,
mail_to_send = EmailMessage(
obj,
template.render(context),
GeneralOption.get_cached_value("email_from"),
[to_addr],
fail_silently=False,
reply_to=[self.email],
)
mail_to_send.send(fail_silently=False)
def can_view(self, user_request, *_args, **_kwargs):
""" Check that the user has the right to view the ticket
@ -137,4 +137,4 @@ def ticket_post_save(**kwargs):
if kwargs["created"]:
if TicketOption.get_cached_value("publish_address"):
ticket = kwargs["instance"]
ticket.publish_mail(ticket.request)
ticket.publish_mail()

View file

@ -42,4 +42,3 @@ class EditTicketOptionForm(FormRevMixin, ModelForm):
prefix = kwargs.pop("prefix", self.Meta.model.__name__)
super(EditTicketOptionForm, self).__init__(*args, prefix=prefix, **kwargs)
self.fields["publish_address"].label = _("Publish address")
self.fields["mail_language"].label = _("Mail language")

View file

@ -41,10 +41,6 @@ class TicketOption(AclMixin, PreferencesModel):
max_length=1000,
null=True,
)
LANG_FR = 0
LANG_EN = 1
LANGUES = ((0, _("French")), (1, _("English")))
mail_language = models.IntegerField(choices=LANGUES, default=LANG_FR)
class Meta:
verbose_name = _("tickets options")

View file

@ -49,7 +49,6 @@ def aff_preferences(request):
pref, created = models.TicketOption.objects.get_or_create()
context = {
"preferences": pref,
"language": str(pref.LANGUES[pref.mail_language][1]),
}
return render_to_string(
"tickets/preferences.html", context=context, request=request, using=None

View file

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %}
{% load i18n %}
{% load humanize %}
{% load acl %}
{% block title %}{% trans "Tickets" %}{% endblock %}
@ -57,21 +58,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div class="panel-body">
<p><b>{% trans "Title:" %}</b> {{ticket.title}}</p>
<p><b>{% trans "Description:" %}</b> {{ ticket.description }}</p>
<p><b>{% trans "Description:" %}</b> {{ ticket.description | linebreaks }}</p>
<div class="text-right">
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_form changestatusform %}
{% can_edit ticket %}
<a type="button" href="{% url 'tickets:edit-ticket' ticket.id %}" class="btn btn-info"><p>{% trans "Edit this ticket" %}</p></a>
{% if not ticket.solved %}
{% trans "Mark as solved" as tr_mark_solved %}
{% bootstrap_button tr_mark_solved button_type="submit" button_class='btn-info' %}
<a type="button" href="{% url 'tickets:change-ticket-status' ticket.id %}" class="btn btn-success"><p>{% trans "Mark as solved" %}</p></a>
{% else %}
{% trans "Mark as not solved" as tr_mark_not_solved %}
{% bootstrap_button tr_mark_not_solved button_type="submit" button_class='btn-warning' %}
<a type="button" href="{% url 'tickets:change-ticket-status' ticket.id %}" class="btn btn-warning"><p>{% trans "Mark as unsolved" %}</p></a>
{% endif %}
</form>
{% acl_end %}
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
{% extends 'machines/sidebar.html' %}
{% extends 'users/sidebar.html' %}
{% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
se veut agnostique au réseau considéré, de manière à être installable en
@ -25,25 +25,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load bootstrap3 %}
{% load massive_bootstrap_form %}
{% load i18n %}
{% block title %}{% trans "Ticket" %}{% endblock %}
{% block content %}
<h2> {% trans "Editing of tickets preferences" %}</h2>
<h2>{% trans "Ticket opening" %}</h2>
{% for message in messages %}
<div class="{{ message| bootstrap_message_classes }} alert-dismissable">
<button type="button" class="close" data_dismiss="alert" aria-hidden="true">&#125;</button>
{{ message | safe }}
</div>
{% endfor %}
{% bootstrap_form_errors ticketform %}
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_field preferencesform.publish_address %}
{% bootstrap_field preferencesform.mail_language %}
{% trans "Edit" as tr_edit %}
{% bootstrap_button tr_edit button_type="submit" icon='ok' button_class='btn-success' %}
{% bootstrap_form ticketform %}
{% bootstrap_button action_name button_type="submit" icon='ok' button_class='btn-success' %}
</form>
{% endblock %}

View file

@ -1,59 +0,0 @@
{% extends 'users/sidebar.html' %}
{% comment %}
Re2o est un logiciel d'administration développé initiallement au rezometz. Il
se veut agnostique au réseau considéré, de manière à être installable en
quelques clics.
Copyright © 2017 Gabriel Détraz
Copyright © 2017 Lara Kermarec
Copyright © 2017 Augustin Lemesle
Copyright © 2017 Maël Kervella
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %}
{% load bootstrap3 %}
{% load massive_bootstrap_form %}
{% load i18n %}
{% block title %}{% trans "Ticket" %}{% endblock %}
{% block content %}
<h2>{% trans "Ticket opening" %}</h2>
<form class="form" method="post">
{% csrf_token %}
{% if not user.is_authenticated %}
<p>{% trans "You are not authenticated. Please log in or provide an email address so we can get back to you." %}</p>
{% bootstrap_field ticketform.email %}
{% endif %}
{% bootstrap_field ticketform.title %}
<br>
<p>{% trans "Description of your problem. Please give as much information as possible to help us searching for a solution. Here is some information we might need:" %}</p>
<ul class="list">
<li>
<p> {% trans "The type of your problem (membership, connection, payment etc.)." %}</p>
</li>
<li>
<p> {% trans "The conditions in which you encounter the problem (Wi-Fi/wired connection, on every machines or only one, on a new machine etc.)." %}</p>
</li>
<li>
<p> {% trans "The locations where you encounter the problem (in your room, in a common space, in a specific building etc.)." %}</p>
</ul>
{% bootstrap_field ticketform.description %}
{% trans "Open the ticket" as tr_open %}
{% bootstrap_button tr_open button_type="submit" icon='ok' button_class='btn-success' %}
</form>
{% endblock %}

View file

@ -0,0 +1,14 @@
{% load i18n %}
<br>
<p>{% trans "Description of your problem. Please give as much information as possible to help us searching for a solution. Here is some information we might need:" %}</p>
<ul class="list">
<li>
<p> {% trans "The type of your problem (membership, connection, payment etc.)." %}</p>
</li>
<li>
<p> {% trans "The conditions in which you encounter the problem (Wi-Fi/wired connection, on every machines or only one, on a new machine etc.)." %}</p>
</li>
<li>
<p> {% trans "The locations where you encounter the problem (in your room, in a common space, in a specific building etc.)." %}</p>
</ul>

View file

@ -25,10 +25,6 @@
<td><p>{% trans "No email address, the tickets will not be published." %}</p></td>
{% endif %}
</tr>
<tr>
<th><p>{% trans "Email language" %}</p></th>
<td><p>{{ language }}</p></th>
</tr>
<table class="table">
</table>
</div>

View file

@ -7,6 +7,6 @@ An anonymous user (not authenticated) opened a ticket
Answer to the address:{{ticket.email}}.
{% endif %}
Title: {{ticket.title}}
Title: {{ ticket.title | safe }}
Description: {{ticket.description}}
Description: {{ ticket.description | safe }}

View file

@ -7,6 +7,6 @@ Un utilisateur anonyme (non connecté) a ouvert un ticket.
Répondre à l'adresse : {{ticket.email}}.
{% endif %}
Titre : {{ticket.title}}
Titre : {{ ticket.title | safe }}
Description : {{ticket.description}}
Description : {{ ticket.description | safe }}

View file

@ -31,6 +31,8 @@ from .preferences.views import edit_options
urlpatterns = [
url(r"^$", views.aff_tickets, name="aff-tickets"),
url(r"^(?P<ticketid>[0-9]+)$", views.aff_ticket, name="aff-ticket"),
url(r"^change_ticket_status/(?P<ticketid>[0-9]+)$", views.change_ticket_status, name="change-ticket-status"),
url(r"^edit_ticket/(?P<ticketid>[0-9]+)$", views.edit_ticket, name="edit-ticket"),
url(
r"^edit_options/(?P<section>TicketOption)$",
edit_options,

View file

@ -42,70 +42,71 @@ from preferences.models import GeneralOption
from .models import Ticket
from .forms import NewTicketForm, ChangeStatusTicketForm
from .forms import NewTicketForm, EditTicketForm
def new_ticket(request):
""" Ticket creation view"""
ticketform = NewTicketForm(request.POST or None)
if request.method == "POST":
ticketform = NewTicketForm(request.POST)
ticketform = NewTicketForm(request.POST or None, request=request)
if ticketform.is_valid():
email = ticketform.cleaned_data.get("email")
ticket = ticketform.save(commit=False)
ticket.request = request
if request.user.is_authenticated:
ticket.user = request.user
ticket.save()
ticketform.save()
messages.success(
request,
_(
"Your ticket has been succesfully opened. We will take care of it as soon as possible."
),
)
if not request.user.is_authenticated:
return redirect(reverse("index"))
else:
return redirect(
reverse("users:profil", kwargs={"userid": str(request.user.id)})
)
if not request.user.is_authenticated and email != "":
ticket.save()
messages.success(
request,
_(
"Your ticket has been succesfully opened. We will take care of it as soon as possible."
),
)
return redirect(reverse("index"))
else:
messages.error(
request,
_(
"You are not authenticated. Please log in or provide an email address so we can get back to you."
),
)
return form(
{"ticketform": ticketform}, "tickets/form_ticket.html", request
{"ticketform": ticketform, 'action_name': ("Create a ticket")}, "tickets/edit.html", request
)
else:
ticketform = NewTicketForm
return form({"ticketform": ticketform}, "tickets/form_ticket.html", request)
@login_required
@can_view(Ticket)
def aff_ticket(request, ticket, ticketid):
"""View to display only one 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},
{"ticket": ticket},
)
@login_required
@can_edit(Ticket)
def change_ticket_status(request, ticket, ticketid):
"""View to edit ticket state"""
ticket.solved = not ticket.solved
ticket.save()
return redirect(
reverse("tickets:aff-ticket", kwargs={"ticketid": str(ticketid)})
)
@login_required
@can_edit(Ticket)
def edit_ticket(request, ticket, ticketid):
""" Ticket creation view"""
ticketform = EditTicketForm(request.POST or None, instance=ticket)
if ticketform.is_valid():
ticketform.save()
messages.success(
request,
_(
"Ticket has been updated successfully"
),
)
return redirect(
reverse("tickets:aff-ticket", kwargs={"ticketid": str(ticketid)})
)
return form(
{"ticketform": ticketform, 'action_name': ("Edit this ticket")}, "tickets/edit.html", request
)