8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +00:00

Edition des préférences des tickets sur la page des préférences

This commit is contained in:
Grizzly 2019-08-06 05:10:37 +00:00 committed by Gabriel Detraz
parent 8e403443b5
commit 1d60f62555
5 changed files with 99 additions and 18 deletions

View file

@ -5,19 +5,12 @@ from re2o.mixins import FormRevMixin
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from .models import( from .models import(
Ticket Ticket,
Preferences,
) )
class EditTicketForm(FormRevMixin, ModelForm): class EditTicketForm(FormRevMixin, ModelForm):
"""Formulaire d'edition d'un Ticket""" """Formulaire d'edition d'un Ticket"""
#def __init__(self,*args, **kwargs):
#prefix = kwargs.pop('prefix',self.Meta.model.__name__)
#super(EditTicketForm, self).__init__(*args, prefix=prefix, **kwargs)
#self.fields['title'].label = _("Titre du ticket")
#self.fields['decription'].label = _("Description du ticket")
#self.fields['solved'].label = _("Problème réglé ?")
class Meta: class Meta:
model = Ticket model = Ticket
exclude = ['user','assigned_staff','date'] exclude = ['user','assigned_staff','date']
@ -25,13 +18,13 @@ class EditTicketForm(FormRevMixin, ModelForm):
class NewTicketForm(ModelForm): class NewTicketForm(ModelForm):
""" Creation d'une machine""" """ Creation d'une machine"""
email = forms.EmailField(required=False) email = forms.EmailField(required=False)
class Meta: class Meta:
model = Ticket model = Ticket
fields = ['title', 'description', 'email'] fields = ['title', 'description', 'email']
#def __init(self,*args, **kwargs): class EditPreferencesForm(ModelForm):
#prefix = kwargs.pop('prefix', self.Meta.model.__name__) """ Edition des préférences des tickets """
#super(NewTicketForm, self).__init__(*args, prefix=prefix, **kwargs) class Meta:
model = Preferences
fields = '__all__'

View file

@ -0,0 +1,48 @@
{% extends 'machines/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 Goulven 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> Edition des préférences des Tickets</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 %}
<form class="form" method="post">
{% csrf_token %}
{% bootstrap_field preferencesform.publish_address %}
{% bootstrap_button "Editer" button_type="submit" icon='ok' button_class='btn-success' %}
</form>
{% endblock %}

View file

@ -6,7 +6,28 @@
<a><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a> <a><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a>
</h4> </h4>
</div> </div>
<div id="collapse_tickets" class="panel-collapse panel-body collapse">
preferences des tickets <div id="collapse_tickets" class="panel-collapse panel-body collapse">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'tickets:edit-preferences-tickets' %}">
<i class="fa fa-edit"></i>
{% trans "Edit" %}
</a>
<p></p>
<div class="table-responsive">
<table class="table">
<tr>
<th><p>Email de publication</p></th>
{% if preferences.publish_address %}
<td><p>{{ preferences.publish_address }}</p></td>
{% else %}
<td><p>{% trans "Pas d'adresse, les tickets ne sont pas annoncés" %}</p></td>
{% endif %}
</tr>
<table class="table">
</table>
</div>
</div> </div>
</div> </div>

View file

@ -5,5 +5,6 @@ from . import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.aff_tickets, name='aff-tickets'), url(r'^$', views.aff_tickets, name='aff-tickets'),
url(r'^ticket/(?P<ticketid>[0-9]+)$', views.aff_ticket, name='aff-ticket'), url(r'^ticket/(?P<ticketid>[0-9]+)$', views.aff_ticket, name='aff-ticket'),
url(r'^ticket/edit-preferences-tickets$', views.edit_preferences, name='edit-preferences-tickets'),
url(r'^new_ticket/$',views.new_ticket,name='new-ticket'), url(r'^new_ticket/$',views.new_ticket,name='new-ticket'),
] ]

View file

@ -11,13 +11,14 @@ from .models import(
) )
from .forms import ( from .forms import (
NewTicketForm NewTicketForm,
EditPreferencesForm,
) )
def new_ticket(request): def new_ticket(request):
""" Vue de création d'un ticket """ """ Vue de création d'un ticket """
ticketform = NewTicketForm(request.POST or None)#, user=request.user) ticketform = NewTicketForm(request.POST or None)
if request.method == 'POST': if request.method == 'POST':
ticketform = NewTicketForm(request.POST) ticketform = NewTicketForm(request.POST)
@ -54,6 +55,23 @@ def aff_tickets(request):
return render(request,'tickets/index.html', return render(request,'tickets/index.html',
{'tickets_list':tickets}) {'tickets_list':tickets})
def edit_preferences(request):
""" Vue d'édition des préférences des tickets """
preferences_instance, created = Preferences.objects.get_or_create(id=1)
preferencesform = EditPreferencesForm(
request.POST or None,
instance = preferences_instance,)
if preferencesform.is_valid():
if preferencesform.changed_data:
preferencesform.save()
messages.success(request,'Préférences des Tickets mises à jour')
return redirect(reverse('preferences:display-options',))
else:
messages.error(request,'Formulaire Invalide')
return form({'preferencesform':preferencesform,},'tickets/form_preferences.html',request)
return form({'preferencesform':preferencesform,},'tickets/form_preferences.html',request)
# views cannoniques des apps optionnels # views cannoniques des apps optionnels
def profil(request,user): def profil(request,user):