mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
ffichage des reminders dans les preferences
This commit is contained in:
parent
064ec73cbc
commit
d78c5f30d2
5 changed files with 86 additions and 52 deletions
54
preferences/templates/preferences/aff_reminder.html
Normal file
54
preferences/templates/preferences/aff_reminder.html
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{% 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
|
||||||
|
|
||||||
|
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 acl %}
|
||||||
|
{% load logs_extra %}
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nombre de jours avant le rappel</th>
|
||||||
|
<th>Message custom pour ce rappel</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for reminder in reminder_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ reminder.days }}</td>
|
||||||
|
<td>{{ reminder.message }}</td>
|
||||||
|
<td class="text-right">
|
||||||
|
{% can_edit reminder %}
|
||||||
|
{% include 'buttons/edit.html' with href='preferences:edit-reminder' id=reminder.id %}
|
||||||
|
{% can_delete reminder %}
|
||||||
|
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'preferences:del-reminder' reminder.id %}">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</a>
|
||||||
|
{% acl_end %}
|
||||||
|
{% acl_end %}
|
||||||
|
{% history_button reminder %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{% can_edit service%}
|
{% can_edit service%}
|
||||||
{% include 'buttons/edit.html' with href='preferences:edit-service' id=service.id %}
|
{% include 'buttons/edit.html' with href='preferences:edit-service' id=service.id %}
|
||||||
|
{% can_delete service %}
|
||||||
|
<a class="btn btn-danger btn-sm" role="button" title="Supprimer" href="{% url 'preferences:del-service' service.id %}">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</a>
|
||||||
|
{% acl_end %}
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
{% history_button service %}
|
{% history_button service %}
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -277,11 +277,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<td>{{ mailmessageoptions.welcome_mail_en|safe }}</td>
|
<td>{{ mailmessageoptions.welcome_mail_en|safe }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<h4>Options pour le mail de fin d'adhésion</h2>
|
||||||
|
{% can_create preferences.Reminder%}
|
||||||
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-reminder' %}"><i class="fa fa-plus"></i> Ajouter un rappel</a>
|
||||||
|
{% acl_end %}
|
||||||
|
{% include "preferences/aff_reminder.html" with reminder_list=reminder_list %}
|
||||||
|
|
||||||
<h4>{% trans "List of services and homepage preferences" %}</h4>
|
<h4>{% trans "List of services and homepage preferences" %}</h4>
|
||||||
{% can_create preferences.Service%}
|
{% can_create preferences.Service%}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-service' %}"><i class="fa fa-plus"></i>{% trans " Add a service" %}</a>
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-service' %}"><i class="fa fa-plus"></i>{% trans " Add a service" %}</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'preferences:del-service' %}"><i class="fa fa-trash"></i>{% trans " Delete one or several services" %}</a>
|
|
||||||
{% include "preferences/aff_service.html" with service_list=service_list %}
|
{% include "preferences/aff_service.html" with service_list=service_list %}
|
||||||
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'HomeOption' %}">
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'HomeOption' %}">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
|
|
|
@ -72,7 +72,7 @@ urlpatterns = [
|
||||||
views.edit_service,
|
views.edit_service,
|
||||||
name='edit-service'
|
name='edit-service'
|
||||||
),
|
),
|
||||||
url(r'^del_service/$', views.del_service, name='del-service'),
|
url(r'^del_service/(?P<serviceid>[0-9]+)$', views.del_service, name='del-service'),
|
||||||
url(r'^add_mailcontact/$', views.add_mailcontact, name='add-mailcontact'),
|
url(r'^add_mailcontact/$', views.add_mailcontact, name='add-mailcontact'),
|
||||||
url(
|
url(
|
||||||
r'^edit_mailcontact/(?P<mailcontactid>[0-9]+)$',
|
r'^edit_mailcontact/(?P<mailcontactid>[0-9]+)$',
|
||||||
|
@ -86,7 +86,7 @@ urlpatterns = [
|
||||||
views.edit_reminder,
|
views.edit_reminder,
|
||||||
name='edit-reminder'
|
name='edit-reminder'
|
||||||
),
|
),
|
||||||
url(r'^del_reminder/$', views.del_reminder, name='del-reminder'),
|
url(r'^del_reminder/(?P<reminderid>[0-9]+)$', views.del_reminder, name='del-reminder'),
|
||||||
url(r'^add_radiuskey/$', views.add_radiuskey, name='add-radiuskey'),
|
url(r'^add_radiuskey/$', views.add_radiuskey, name='add-radiuskey'),
|
||||||
url(
|
url(
|
||||||
r'^edit_radiuskey/(?P<radiuskeyid>[0-9]+)$',
|
r'^edit_radiuskey/(?P<radiuskeyid>[0-9]+)$',
|
||||||
|
|
|
@ -146,10 +146,7 @@ def add_service(request):
|
||||||
"""Ajout d'un service de la page d'accueil"""
|
"""Ajout d'un service de la page d'accueil"""
|
||||||
service = ServiceForm(request.POST or None, request.FILES or None)
|
service = ServiceForm(request.POST or None, request.FILES or None)
|
||||||
if service.is_valid():
|
if service.is_valid():
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
service.save()
|
service.save()
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment("Creation")
|
|
||||||
messages.success(request, _("The service was added."))
|
messages.success(request, _("The service was added."))
|
||||||
return redirect(reverse('preferences:display-options'))
|
return redirect(reverse('preferences:display-options'))
|
||||||
return form(
|
return form(
|
||||||
|
@ -169,14 +166,7 @@ def edit_service(request, service_instance, **_kwargs):
|
||||||
instance=service_instance
|
instance=service_instance
|
||||||
)
|
)
|
||||||
if service.is_valid():
|
if service.is_valid():
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
service.save()
|
service.save()
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment(
|
|
||||||
"Field(s) edited: %s" % ', '.join(
|
|
||||||
field for field in service.changed_data
|
|
||||||
)
|
|
||||||
)
|
|
||||||
messages.success(request, _("The service was edited."))
|
messages.success(request, _("The service was edited."))
|
||||||
return redirect(reverse('preferences:display-options'))
|
return redirect(reverse('preferences:display-options'))
|
||||||
return form(
|
return form(
|
||||||
|
@ -185,70 +175,50 @@ def edit_service(request, service_instance, **_kwargs):
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_delete_set(Service)
|
@can_delete(Service)
|
||||||
def del_service(request, instances):
|
def del_service(request, service_instance, **_kwargs):
|
||||||
"""Suppression d'un service de la page d'accueil"""
|
"""Suppression d'un service de la page d'accueil"""
|
||||||
services = DelServiceForm(request.POST or None, instances=instances)
|
if request.method == "POST":
|
||||||
if services.is_valid():
|
service_instance.delete()
|
||||||
services_dels = services.cleaned_data['services']
|
messages.success(request, "Le service a été détruit")
|
||||||
for services_del in services_dels:
|
|
||||||
try:
|
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
services_del.delete()
|
|
||||||
reversion.set_user(request.user)
|
|
||||||
messages.success(request, _("The service was deleted."))
|
|
||||||
except ProtectedError:
|
|
||||||
messages.error(request, _("Error: the service %s can't be"
|
|
||||||
" deleted.") % services_del)
|
|
||||||
return redirect(reverse('preferences:display-options'))
|
return redirect(reverse('preferences:display-options'))
|
||||||
return form(
|
return form(
|
||||||
{'preferenceform': services, 'action_name': _("Delete")},
|
{'objet': service_instance, 'objet_name': 'service'},
|
||||||
'preferences/preferences.html',
|
'preferences/delete.html',
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_create(Reminder)
|
@can_create(Reminder)
|
||||||
def add_reminder(request):
|
def add_reminder(request):
|
||||||
"""Ajout d'un service de la page d'accueil"""
|
"""Ajout d'un mail de rappel"""
|
||||||
reminder = ReminderForm(request.POST or None, request.FILES or None)
|
reminder = ReminderForm(request.POST or None, request.FILES or None)
|
||||||
if service.is_valid():
|
if reminder.is_valid():
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
reminder.save()
|
reminder.save()
|
||||||
reversion.set_user(request.user)
|
messages.success(request, _("The reminder was added."))
|
||||||
reversion.set_comment("Creation")
|
|
||||||
messages.success(request, _("The service was added."))
|
|
||||||
return redirect(reverse('preferences:display-options'))
|
return redirect(reverse('preferences:display-options'))
|
||||||
return form(
|
return form(
|
||||||
{'preferenceform': service, 'action_name': _("Add a service")},
|
{'preferenceform': reminder, 'action_name': _("Add a service")},
|
||||||
'preferences/preferences.html',
|
'preferences/preferences.html',
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Reminder)
|
@can_edit(Reminder)
|
||||||
def edit_reminder(request, service_instance, **_kwargs):
|
def edit_reminder(request, reminder_instance, **_kwargs):
|
||||||
"""Edition des services affichés sur la page d'accueil"""
|
"""Edition reminder"""
|
||||||
reminder = ReminderForm(
|
reminder = ReminderForm(
|
||||||
request.POST or None,
|
request.POST or None,
|
||||||
request.FILES or None,
|
request.FILES or None,
|
||||||
instance=reminder_instance
|
instance=reminder_instance
|
||||||
)
|
)
|
||||||
if reminder.is_valid():
|
if reminder.is_valid():
|
||||||
with transaction.atomic(), reversion.create_revision():
|
|
||||||
reminder.save()
|
reminder.save()
|
||||||
reversion.set_user(request.user)
|
|
||||||
reversion.set_comment(
|
|
||||||
"Field(s) edited: %s" % ', '.join(
|
|
||||||
field for field in reminder.changed_data
|
|
||||||
)
|
|
||||||
)
|
|
||||||
messages.success(request, _("The service was edited."))
|
messages.success(request, _("The service was edited."))
|
||||||
return redirect(reverse('preferences:display-options'))
|
return redirect(reverse('preferences:display-options'))
|
||||||
return form(
|
return form(
|
||||||
{'preferenceform': service, 'action_name': _("Edit")},
|
{'preferenceform': reminder, 'action_name': _("Edit")},
|
||||||
'preferences/preferences.html',
|
'preferences/preferences.html',
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue