8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-28 01:43:46 +00:00

Merge branch 'reminder-display' into 'dev'

ffichage des reminders dans les preferences

See merge request federez/re2o!321
This commit is contained in:
chirac 2018-09-30 20:36:47 +02:00
commit f6dc63aac2
5 changed files with 86 additions and 52 deletions

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

View file

@ -44,6 +44,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td class="text-right">
{% can_edit service%}
{% 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 %}
{% history_button service %}
</td>

View file

@ -277,11 +277,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ mailmessageoptions.welcome_mail_en|safe }}</td>
</tr>
</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>
{% 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>
{% 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 %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'HomeOption' %}">
<i class="fa fa-edit"></i>

View file

@ -72,7 +72,7 @@ urlpatterns = [
views.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'^edit_mailcontact/(?P<mailcontactid>[0-9]+)$',
@ -86,7 +86,7 @@ urlpatterns = [
views.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'^edit_radiuskey/(?P<radiuskeyid>[0-9]+)$',

View file

@ -146,10 +146,7 @@ def add_service(request):
"""Ajout d'un service de la page d'accueil"""
service = ServiceForm(request.POST or None, request.FILES or None)
if service.is_valid():
with transaction.atomic(), reversion.create_revision():
service.save()
reversion.set_user(request.user)
reversion.set_comment("Creation")
service.save()
messages.success(request, _("The service was added."))
return redirect(reverse('preferences:display-options'))
return form(
@ -169,14 +166,7 @@ def edit_service(request, service_instance, **_kwargs):
instance=service_instance
)
if service.is_valid():
with transaction.atomic(), reversion.create_revision():
service.save()
reversion.set_user(request.user)
reversion.set_comment(
"Field(s) edited: %s" % ', '.join(
field for field in service.changed_data
)
)
service.save()
messages.success(request, _("The service was edited."))
return redirect(reverse('preferences:display-options'))
return form(
@ -185,70 +175,50 @@ def edit_service(request, service_instance, **_kwargs):
request
)
@login_required
@can_delete_set(Service)
def del_service(request, instances):
@can_delete(Service)
def del_service(request, service_instance, **_kwargs):
"""Suppression d'un service de la page d'accueil"""
services = DelServiceForm(request.POST or None, instances=instances)
if services.is_valid():
services_dels = services.cleaned_data['services']
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)
if request.method == "POST":
service_instance.delete()
messages.success(request, "Le service a été détruit")
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': services, 'action_name': _("Delete")},
'preferences/preferences.html',
{'objet': service_instance, 'objet_name': 'service'},
'preferences/delete.html',
request
)
)
@login_required
@can_create(Reminder)
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)
if service.is_valid():
with transaction.atomic(), reversion.create_revision():
reminder.save()
reversion.set_user(request.user)
reversion.set_comment("Creation")
messages.success(request, _("The service was added."))
if reminder.is_valid():
reminder.save()
messages.success(request, _("The reminder was added."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': service, 'action_name': _("Add a service")},
{'preferenceform': reminder, 'action_name': _("Add a service")},
'preferences/preferences.html',
request
)
@login_required
@can_edit(Reminder)
def edit_reminder(request, service_instance, **_kwargs):
"""Edition des services affichés sur la page d'accueil"""
def edit_reminder(request, reminder_instance, **_kwargs):
"""Edition reminder"""
reminder = ReminderForm(
request.POST or None,
request.FILES or None,
instance=reminder_instance
)
if reminder.is_valid():
with transaction.atomic(), reversion.create_revision():
reminder.save()
reversion.set_user(request.user)
reversion.set_comment(
"Field(s) edited: %s" % ', '.join(
field for field in reminder.changed_data
)
)
reminder.save()
messages.success(request, _("The service was edited."))
return redirect(reverse('preferences:display-options'))
return form(
{'preferenceform': service, 'action_name': _("Edit")},
{'preferenceform': reminder, 'action_name': _("Edit")},
'preferences/preferences.html',
request
)