mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Affichage des préférences des tickets
This commit is contained in:
parent
575e570d16
commit
8e403443b5
5 changed files with 57 additions and 1 deletions
|
@ -503,5 +503,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% for template in optionnal_templates_list %}
|
||||||
|
{{ template }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
|
from importlib import import_module
|
||||||
|
from re2o.settings_local import OPTIONNAL_APPS
|
||||||
from re2o.views import form
|
from re2o.views import form
|
||||||
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all, can_delete
|
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all, can_delete
|
||||||
|
|
||||||
|
@ -94,6 +96,10 @@ def display_options(request):
|
||||||
radiusoptions, _ = RadiusOption.objects.get_or_create()
|
radiusoptions, _ = RadiusOption.objects.get_or_create()
|
||||||
cotisationsoptions, _created = CotisationsOption.objects.get_or_create()
|
cotisationsoptions, _created = CotisationsOption.objects.get_or_create()
|
||||||
document_template_list = DocumentTemplate.objects.order_by('name')
|
document_template_list = DocumentTemplate.objects.order_by('name')
|
||||||
|
|
||||||
|
optionnal_apps = [import_module(app) for app in OPTIONNAL_APPS]
|
||||||
|
optionnal_templates_list = [app.views.preferences(request) for app in optionnal_apps]
|
||||||
|
|
||||||
return form({
|
return form({
|
||||||
'useroptions': useroptions,
|
'useroptions': useroptions,
|
||||||
'machineoptions': machineoptions,
|
'machineoptions': machineoptions,
|
||||||
|
@ -109,6 +115,7 @@ def display_options(request):
|
||||||
'switchmanagementcred_list': switchmanagementcred_list,
|
'switchmanagementcred_list': switchmanagementcred_list,
|
||||||
'radiusoptions' : radiusoptions,
|
'radiusoptions' : radiusoptions,
|
||||||
'cotisationsoptions': cotisationsoptions,
|
'cotisationsoptions': cotisationsoptions,
|
||||||
|
'optionnal_templates_list': optionnal_templates_list,
|
||||||
'document_template_list': document_template_list,
|
'document_template_list': document_template_list,
|
||||||
}, 'preferences/display_preferences.html', request)
|
}, 'preferences/display_preferences.html', request)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.core.mail import send_mail
|
||||||
|
from django.template import Context, loader
|
||||||
|
|
||||||
import users.models
|
import users.models
|
||||||
|
|
||||||
|
@ -42,3 +44,23 @@ class Ticket(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Ticket de {} date: {}".format(self.user.surname,self.date)
|
return "Ticket de {} date: {}".format(self.user.surname,self.date)
|
||||||
|
|
||||||
|
def publish_mail(self):
|
||||||
|
template = loader.get_template('ticket/mail_publish_ticket')
|
||||||
|
context = Context({'ticket':self})
|
||||||
|
send_mail(
|
||||||
|
'Nouvelle ouverture de ticket',
|
||||||
|
'',
|
||||||
|
'ticket_app_re2o@crans.org',
|
||||||
|
'',
|
||||||
|
html_message=template.render(context))
|
||||||
|
|
||||||
|
class Preferences(models.Model):
|
||||||
|
""" Class cannonique définissants les préférences des tickets """
|
||||||
|
|
||||||
|
publish_address = models.EmailField(
|
||||||
|
help_text = _("Adresse mail pour annoncer les nouveau tickets (laisser vide pour ne rien annoncer)"),
|
||||||
|
max_length = 1000,
|
||||||
|
null = True)
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _("Préférences des tickets")
|
||||||
|
|
12
tickets/templates/tickets/preferences.html
Normal file
12
tickets/templates/tickets/preferences.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<div class="panel panel-default" id="tickets">
|
||||||
|
<div class="panel-heading" data-toggle="collapse" href="#collapse_tickets">
|
||||||
|
<h4 class="panel-title">
|
||||||
|
<a><i class="fa fa-ticket"></i> {% trans "Tickets" %}</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div id="collapse_tickets" class="panel-collapse panel-body collapse">
|
||||||
|
preferences des tickets
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -6,13 +6,15 @@ from django.forms import modelformset_factory
|
||||||
from re2o.views import form
|
from re2o.views import form
|
||||||
|
|
||||||
from .models import(
|
from .models import(
|
||||||
Ticket
|
Ticket,
|
||||||
|
Preferences,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
NewTicketForm
|
NewTicketForm
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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)#, user=request.user)
|
||||||
|
@ -51,8 +53,17 @@ def aff_tickets(request):
|
||||||
tickets = Ticket.objects.all().order_by('-date')
|
tickets = Ticket.objects.all().order_by('-date')
|
||||||
return render(request,'tickets/index.html',
|
return render(request,'tickets/index.html',
|
||||||
{'tickets_list':tickets})
|
{'tickets_list':tickets})
|
||||||
|
|
||||||
|
|
||||||
|
# views cannoniques des apps optionnels
|
||||||
def profil(request,user):
|
def profil(request,user):
|
||||||
""" Vue cannonique d'affichage des tickets dans l'accordeon du profil"""
|
""" Vue cannonique d'affichage des tickets dans l'accordeon du profil"""
|
||||||
tickets = Ticket.objects.filter(user=user).all().order_by('-date')
|
tickets = Ticket.objects.filter(user=user).all().order_by('-date')
|
||||||
context = {'tickets_list':tickets}
|
context = {'tickets_list':tickets}
|
||||||
return render_to_string('tickets/profil.html', context=context, request=request, using=None)
|
return render_to_string('tickets/profil.html', context=context, request=request, using=None)
|
||||||
|
|
||||||
|
def preferences(request):
|
||||||
|
""" Vue cannonique d'affichage des tickets dans l'affichage du profil"""
|
||||||
|
preferences = Preferences.objects.first()
|
||||||
|
context = {'preferences':preferences}
|
||||||
|
return render_to_string('tickets/preferences.html', context=context, request=request, using=None)
|
||||||
|
|
Loading…
Reference in a new issue