mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Merge branch 'contact' into 'master'
Contact See merge request federez/re2o!200
This commit is contained in:
commit
ea7ea032f0
15 changed files with 378 additions and 11 deletions
|
@ -34,6 +34,7 @@ from .models import (
|
||||||
OptionalTopologie,
|
OptionalTopologie,
|
||||||
GeneralOption,
|
GeneralOption,
|
||||||
Service,
|
Service,
|
||||||
|
MailContact,
|
||||||
AssoOption,
|
AssoOption,
|
||||||
MailMessageOption,
|
MailMessageOption,
|
||||||
HomeOption
|
HomeOption
|
||||||
|
@ -65,6 +66,11 @@ class ServiceAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MailContactAdmin(VersionAdmin):
|
||||||
|
"""Admin class for contact email adresses"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AssoOptionAdmin(VersionAdmin):
|
class AssoOptionAdmin(VersionAdmin):
|
||||||
"""Class admin options de l'asso"""
|
"""Class admin options de l'asso"""
|
||||||
pass
|
pass
|
||||||
|
@ -86,5 +92,6 @@ admin.site.register(OptionalTopologie, OptionalTopologieAdmin)
|
||||||
admin.site.register(GeneralOption, GeneralOptionAdmin)
|
admin.site.register(GeneralOption, GeneralOptionAdmin)
|
||||||
admin.site.register(HomeOption, HomeOptionAdmin)
|
admin.site.register(HomeOption, HomeOptionAdmin)
|
||||||
admin.site.register(Service, ServiceAdmin)
|
admin.site.register(Service, ServiceAdmin)
|
||||||
|
admin.site.register(MailContact, MailContactAdmin)
|
||||||
admin.site.register(AssoOption, AssoOptionAdmin)
|
admin.site.register(AssoOption, AssoOptionAdmin)
|
||||||
admin.site.register(MailMessageOption, MailMessageOptionAdmin)
|
admin.site.register(MailMessageOption, MailMessageOptionAdmin)
|
||||||
|
|
|
@ -27,6 +27,8 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.forms import ModelForm, Form
|
from django.forms import ModelForm, Form
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
|
from re2o.mixins import FormRevMixin
|
||||||
from .models import (
|
from .models import (
|
||||||
OptionalUser,
|
OptionalUser,
|
||||||
OptionalMachine,
|
OptionalMachine,
|
||||||
|
@ -35,7 +37,8 @@ from .models import (
|
||||||
AssoOption,
|
AssoOption,
|
||||||
MailMessageOption,
|
MailMessageOption,
|
||||||
HomeOption,
|
HomeOption,
|
||||||
Service
|
Service,
|
||||||
|
MailContact
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,3 +230,30 @@ class DelServiceForm(Form):
|
||||||
self.fields['services'].queryset = instances
|
self.fields['services'].queryset = instances
|
||||||
else:
|
else:
|
||||||
self.fields['services'].queryset = Service.objects.all()
|
self.fields['services'].queryset = Service.objects.all()
|
||||||
|
|
||||||
|
class MailContactForm(FormRevMixin, ModelForm):
|
||||||
|
"""Edit and add contact email adress"""
|
||||||
|
class Meta:
|
||||||
|
model = MailContact
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
|
super(MailContactForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class DelMailContactForm(Form):
|
||||||
|
"""Delete contact email adress"""
|
||||||
|
mailcontacts = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=MailContact.objects.none(),
|
||||||
|
label="Enregistrements adresses actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
instances = kwargs.pop('instances', None)
|
||||||
|
super(DelMailContactForm, self).__init__(*args, **kwargs)
|
||||||
|
if instances:
|
||||||
|
self.fields['mailcontacts'].queryset = instances
|
||||||
|
else:
|
||||||
|
self.fields['mailcontacts'].queryset = MailContact.objects.all()
|
||||||
|
|
BIN
preferences/locale/fr/LC_MESSAGES/django.mo
Normal file
BIN
preferences/locale/fr/LC_MESSAGES/django.mo
Normal file
Binary file not shown.
70
preferences/locale/fr/LC_MESSAGES/django.po
Normal file
70
preferences/locale/fr/LC_MESSAGES/django.po
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# SOME DESCRIPTIVE TITLE.
|
||||||
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||||
|
# This file is distributed under the same license as the PACKAGE package.
|
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||||
|
#
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2018-07-26 21:49+0200\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
|
#: models.py:256
|
||||||
|
msgid "Contact email adress"
|
||||||
|
msgstr "Adresse email de contact"
|
||||||
|
|
||||||
|
#: models.py:263
|
||||||
|
msgid "Description of the associated email adress."
|
||||||
|
msgstr "Description de l'adresse mail associée."
|
||||||
|
|
||||||
|
#: models.py:273
|
||||||
|
msgid "Can see contact email"
|
||||||
|
msgstr "Peut voir un mail de contact"
|
||||||
|
|
||||||
|
#: templates/preferences/aff_mailcontact.html:30
|
||||||
|
msgid "Adress"
|
||||||
|
msgstr "Adresse"
|
||||||
|
|
||||||
|
#: templates/preferences/aff_mailcontact.html:31
|
||||||
|
msgid "Remark"
|
||||||
|
msgstr "Commentaire"
|
||||||
|
|
||||||
|
#: templates/preferences/display_preferences.html:205
|
||||||
|
msgid "Contact email adresses list"
|
||||||
|
msgstr "Liste des adresses email de contact"
|
||||||
|
|
||||||
|
#: templates/preferences/display_preferences.html:207
|
||||||
|
msgid "Add an adress"
|
||||||
|
msgstr "Ajouter une adresse"
|
||||||
|
|
||||||
|
#: templates/preferences/display_preferences.html:209
|
||||||
|
msgid "Delete one or multiple adresses"
|
||||||
|
msgstr "Supprimer une ou plusieurs adresses"
|
||||||
|
|
||||||
|
#: views.py:210
|
||||||
|
msgid "The adress was created."
|
||||||
|
msgstr "L'adresse a été créée."
|
||||||
|
|
||||||
|
#: views.py:230
|
||||||
|
msgid "Email adress updated."
|
||||||
|
msgstr "L'adresse email a été mise à jour."
|
||||||
|
|
||||||
|
#: views.py:233
|
||||||
|
msgid "Edit"
|
||||||
|
msgstr "Éditer"
|
||||||
|
|
||||||
|
#: views.py:251
|
||||||
|
msgid "The email adress was deleted."
|
||||||
|
msgstr "L'adresse email a été supprimée."
|
||||||
|
|
||||||
|
#: views.py:254
|
||||||
|
msgid "Delete"
|
||||||
|
msgstr "Supprimer"
|
28
preferences/migrations/0047_mailcontact.py
Normal file
28
preferences/migrations/0047_mailcontact.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2018-06-30 15:27
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import re2o.mixins
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0046_optionaluser_mail_extension'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MailContact',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('address', models.EmailField(default='contact@example.org', help_text="Contact email adress", max_length=254)),
|
||||||
|
('commentary', models.CharField(blank=True, help_text="Description of the associated email adress.", max_length=256, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'permissions': (('view_mailcontact', "Can see contact email"),),
|
||||||
|
},
|
||||||
|
bases=(re2o.mixins.AclMixin, models.Model),
|
||||||
|
),
|
||||||
|
]
|
|
@ -31,6 +31,7 @@ from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.forms import ValidationError
|
from django.forms import ValidationError
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import machines.models
|
import machines.models
|
||||||
from re2o.mixins import AclMixin
|
from re2o.mixins import AclMixin
|
||||||
|
@ -267,6 +268,34 @@ class Service(AclMixin, models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
|
class MailContact(AclMixin, models.Model):
|
||||||
|
"""Contact email adress with a commentary."""
|
||||||
|
|
||||||
|
address = models.EmailField(
|
||||||
|
default = "contact@example.org",
|
||||||
|
help_text = _("Contact email adress")
|
||||||
|
)
|
||||||
|
|
||||||
|
commentary = models.CharField(
|
||||||
|
blank = True,
|
||||||
|
null = True,
|
||||||
|
help_text = _(
|
||||||
|
"Description of the associated email adress."),
|
||||||
|
max_length = 256
|
||||||
|
)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def get_name(self):
|
||||||
|
return self.address.split("@")[0]
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
permissions = (
|
||||||
|
("view_mailcontact", _("Can see contact email")),
|
||||||
|
)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return(self.address)
|
||||||
|
|
||||||
|
|
||||||
class AssoOption(AclMixin, PreferencesModel):
|
class AssoOption(AclMixin, PreferencesModel):
|
||||||
"""Options générales de l'asso : siret, addresse, nom, etc"""
|
"""Options générales de l'asso : siret, addresse, nom, etc"""
|
||||||
|
|
47
preferences/templates/preferences/aff_mailcontact.html
Normal file
47
preferences/templates/preferences/aff_mailcontact.html
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{% 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 i18n %}
|
||||||
|
{% load acl %}
|
||||||
|
{% load logs_extra %}
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{% trans "Adress" %}</th>
|
||||||
|
<th>{% trans "Remark" %}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
{% for mailcontact in mailcontact_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ mailcontact.address }}</td>
|
||||||
|
<td>{{ mailcontact.commentary }}</td>
|
||||||
|
<td class="text-right">
|
||||||
|
{% can_edit mailcontact %}
|
||||||
|
{% include 'buttons/edit.html' with href='preferences:edit-mailcontact' id=mailcontact.id %}
|
||||||
|
{% acl_end %}
|
||||||
|
{% history_button mailcontact %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
|
@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
{% load acl %}
|
{% load acl %}
|
||||||
{% load design %}
|
{% load design %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}Création et modification des préférences{% endblock %}
|
{% block title %}Création et modification des préférences{% endblock %}
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</i> Ajouter un service
|
</i> Ajouter un service
|
||||||
</a>
|
</a>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
<a class="btn btn-danger btn-sm" role="button" href="{% url 'preferences:del-services' %}"><i class="fa fa-trash">
|
<a class="btn btn-danger btn-sm" role="button" href="{% url 'preferences:del-service' %}"><i class="fa fa-trash">
|
||||||
</i> Supprimer un ou plusieurs service
|
</i> Supprimer un ou plusieurs service
|
||||||
</a>
|
</a>
|
||||||
{% include "preferences/aff_service.html" with service_list=service_list %}
|
{% include "preferences/aff_service.html" with service_list=service_list %}
|
||||||
|
@ -220,6 +221,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<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> Editer
|
<i class="fa fa-edit"></i> Editer
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<h2>{% trans "Contact email adresses list" %}</h2>
|
||||||
|
{% can_create preferences.MailContact%}
|
||||||
|
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-mailcontact' %}"><i class="fa fa-plus"></i>{% trans "Add an adress" %}</a>
|
||||||
|
{% acl_end %}
|
||||||
|
<a class="btn btn-danger btn-sm" role="button" href="{% url 'preferences:del-mailcontact' %}"><i class="fa fa-trash"></i>{% trans "Delete one or multiple adresses" %}</a>
|
||||||
|
{% include "preferences/aff_mailcontact.html" with mailcontact_list=mailcontact_list %}
|
||||||
|
<p>
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Url du compte twitter</th>
|
<th>Url du compte twitter</th>
|
||||||
|
|
|
@ -72,6 +72,13 @@ urlpatterns = [
|
||||||
views.edit_service,
|
views.edit_service,
|
||||||
name='edit-service'
|
name='edit-service'
|
||||||
),
|
),
|
||||||
url(r'^del_services/$', views.del_services, name='del-services'),
|
url(r'^del_service/$', views.del_service, name='del-service'),
|
||||||
|
url(r'^add_mailcontact/$', views.add_mailcontact, name='add-mailcontact'),
|
||||||
|
url(
|
||||||
|
r'^edit_mailcontact/(?P<mailcontactid>[0-9]+)$',
|
||||||
|
views.edit_mailcontact,
|
||||||
|
name='edit-mailcontact'
|
||||||
|
),
|
||||||
|
url(r'^del_mailcontact/$', views.del_mailcontact, name='del-mailcontact'),
|
||||||
url(r'^$', views.display_options, name='display-options'),
|
url(r'^$', views.display_options, name='display-options'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -36,15 +36,19 @@ from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.db.models import ProtectedError
|
from django.db.models import ProtectedError
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
|
|
||||||
from re2o.views import form
|
from re2o.views import form
|
||||||
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all
|
from re2o.acl import can_create, can_edit, can_delete_set, can_view_all
|
||||||
|
|
||||||
from .forms import ServiceForm, DelServiceForm
|
from .forms import (
|
||||||
|
ServiceForm, DelServiceForm, MailContactForm, DelMailContactForm
|
||||||
|
)
|
||||||
from .models import (
|
from .models import (
|
||||||
Service,
|
Service,
|
||||||
|
MailContact,
|
||||||
OptionalUser,
|
OptionalUser,
|
||||||
OptionalMachine,
|
OptionalMachine,
|
||||||
AssoOption,
|
AssoOption,
|
||||||
|
@ -71,6 +75,7 @@ def display_options(request):
|
||||||
homeoptions, _created = HomeOption.objects.get_or_create()
|
homeoptions, _created = HomeOption.objects.get_or_create()
|
||||||
mailmessageoptions, _created = MailMessageOption.objects.get_or_create()
|
mailmessageoptions, _created = MailMessageOption.objects.get_or_create()
|
||||||
service_list = Service.objects.all()
|
service_list = Service.objects.all()
|
||||||
|
mailcontact_list = MailContact.objects.all()
|
||||||
return form({
|
return form({
|
||||||
'useroptions': useroptions,
|
'useroptions': useroptions,
|
||||||
'machineoptions': machineoptions,
|
'machineoptions': machineoptions,
|
||||||
|
@ -79,7 +84,8 @@ def display_options(request):
|
||||||
'assooptions': assooptions,
|
'assooptions': assooptions,
|
||||||
'homeoptions': homeoptions,
|
'homeoptions': homeoptions,
|
||||||
'mailmessageoptions': mailmessageoptions,
|
'mailmessageoptions': mailmessageoptions,
|
||||||
'service_list': service_list
|
'service_list': service_list,
|
||||||
|
'mailcontact_list': mailcontact_list
|
||||||
}, 'preferences/display_preferences.html', request)
|
}, 'preferences/display_preferences.html', request)
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,7 +175,7 @@ def edit_service(request, service_instance, **_kwargs):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_delete_set(Service)
|
@can_delete_set(Service)
|
||||||
def del_services(request, instances):
|
def del_service(request, instances):
|
||||||
"""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)
|
services = DelServiceForm(request.POST or None, instances=instances)
|
||||||
if services.is_valid():
|
if services.is_valid():
|
||||||
|
@ -179,7 +185,7 @@ def del_services(request, instances):
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
services_del.delete()
|
services_del.delete()
|
||||||
reversion.set_user(request.user)
|
reversion.set_user(request.user)
|
||||||
messages.success(request, "Le service a été supprimée")
|
messages.success(request, "Le service a été supprimé")
|
||||||
except ProtectedError:
|
except ProtectedError:
|
||||||
messages.error(request, "Erreur le service\
|
messages.error(request, "Erreur le service\
|
||||||
suivant %s ne peut être supprimé" % services_del)
|
suivant %s ne peut être supprimé" % services_del)
|
||||||
|
@ -189,3 +195,63 @@ def del_services(request, instances):
|
||||||
'preferences/preferences.html',
|
'preferences/preferences.html',
|
||||||
request
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_create(MailContact)
|
||||||
|
def add_mailcontact(request):
|
||||||
|
"""Add a contact email adress."""
|
||||||
|
mailcontact = MailContactForm(
|
||||||
|
request.POST or None,
|
||||||
|
request.FILES or None
|
||||||
|
)
|
||||||
|
if mailcontact.is_valid():
|
||||||
|
mailcontact.save()
|
||||||
|
messages.success(request, _("The adress was created."))
|
||||||
|
return redirect(reverse('preferences:display-options'))
|
||||||
|
return form(
|
||||||
|
{'preferenceform': mailcontact, 'action_name': 'Ajouter'},
|
||||||
|
'preferences/preferences.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_edit(MailContact)
|
||||||
|
def edit_mailcontact(request, mailcontact_instance, **_kwargs):
|
||||||
|
"""Edit contact email adress."""
|
||||||
|
mailcontact = MailContactForm(
|
||||||
|
request.POST or None,
|
||||||
|
request.FILES or None,
|
||||||
|
instance=mailcontact_instance
|
||||||
|
)
|
||||||
|
if mailcontact.is_valid():
|
||||||
|
mailcontact.save()
|
||||||
|
messages.success(request, _("Email adress updated."))
|
||||||
|
return redirect(reverse('preferences:display-options'))
|
||||||
|
return form(
|
||||||
|
{'preferenceform': mailcontact, 'action_name': _('Edit')},
|
||||||
|
'preferences/preferences.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@can_delete_set(MailContact)
|
||||||
|
def del_mailcontact(request, instances):
|
||||||
|
"""Delete an email adress"""
|
||||||
|
mailcontacts = DelMailContactForm(
|
||||||
|
request.POST or None,
|
||||||
|
instances=instances
|
||||||
|
)
|
||||||
|
if mailcontacts.is_valid():
|
||||||
|
mailcontacts_dels = mailcontacts.cleaned_data['mailcontacts']
|
||||||
|
for mailcontacts_del in mailcontacts_dels:
|
||||||
|
mailcontacts_del.delete()
|
||||||
|
messages.success(request, _("The email adress was deleted."))
|
||||||
|
return redirect(reverse('preferences:display-options'))
|
||||||
|
return form(
|
||||||
|
{'preferenceform': mailcontacts, 'action_name': _('Delete')},
|
||||||
|
'preferences/preferences.html',
|
||||||
|
request
|
||||||
|
)
|
||||||
|
|
52
re2o/templates/re2o/contact.html
Normal file
52
re2o/templates/re2o/contact.html
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{% extends "re2o/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
|
||||||
|
|
||||||
|
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 i18n %}
|
||||||
|
|
||||||
|
{% block title %}{% trans "Contact" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>{% blocktrans %}Contacter l'association {{asso_name}}{% endblocktrans %}</h2>
|
||||||
|
</br>
|
||||||
|
|
||||||
|
{% for contact in contacts %}
|
||||||
|
|
||||||
|
<div class="panel panel-info">
|
||||||
|
<div class="panel-heading"><h4>{{ contact.get_name }}</h4></div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-9">{{ contact.commentary}}</div>
|
||||||
|
<div class="col-sm-3"><a href="mailto:{{ contact.address }}">{{ contact.address }}</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -79,7 +79,6 @@ from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
def get_model(model_name):
|
def get_model(model_name):
|
||||||
"""Retrieve the model object from its name"""
|
"""Retrieve the model object from its name"""
|
||||||
splitted = model_name.split('.')
|
splitted = model_name.split('.')
|
||||||
|
|
|
@ -47,7 +47,7 @@ from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
|
|
||||||
from .views import index, about_page
|
from .views import index, about_page, contact_page
|
||||||
|
|
||||||
handler500 = 're2o.views.handler500'
|
handler500 = 're2o.views.handler500'
|
||||||
handler404 = 're2o.views.handler404'
|
handler404 = 're2o.views.handler404'
|
||||||
|
@ -55,6 +55,7 @@ handler404 = 're2o.views.handler404'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', index, name='index'),
|
url(r'^$', index, name='index'),
|
||||||
url(r'^about/$', about_page, name='about'),
|
url(r'^about/$', about_page, name='about'),
|
||||||
|
url(r'^contact/$', contact_page, name='contact'),
|
||||||
url('^logout/', auth_views.logout, {'next_page': '/'}),
|
url('^logout/', auth_views.logout, {'next_page': '/'}),
|
||||||
url('^', include('django.contrib.auth.urls')),
|
url('^', include('django.contrib.auth.urls')),
|
||||||
url(r'^i18n/', include('django.conf.urls.i18n')),
|
url(r'^i18n/', include('django.conf.urls.i18n')),
|
||||||
|
|
|
@ -36,6 +36,8 @@ from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
from preferences.models import (
|
from preferences.models import (
|
||||||
Service,
|
Service,
|
||||||
|
MailContact,
|
||||||
|
GeneralOption,
|
||||||
AssoOption,
|
AssoOption,
|
||||||
HomeOption
|
HomeOption
|
||||||
)
|
)
|
||||||
|
@ -106,6 +108,21 @@ def about_page(request):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def contact_page(request):
|
||||||
|
"""The view for the contact page
|
||||||
|
Send all the objects MailContact
|
||||||
|
"""
|
||||||
|
address = MailContact.objects.all()
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"re2o/contact.html",
|
||||||
|
{
|
||||||
|
'contacts': address,
|
||||||
|
'asso_name': AssoOption.objects.first().name
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def handler500(request):
|
def handler500(request):
|
||||||
"""The handler view for a 500 error"""
|
"""The handler view for a 500 error"""
|
||||||
|
|
|
@ -124,8 +124,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% acl_end %}
|
{% acl_end %}
|
||||||
<li>
|
<li class="dropdown">
|
||||||
<a href="{% url 'about' %}"><i class="fa fa-info-circle"></i> {% trans "About" %}</a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-info"></i> {% trans "Info" %}<span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="{% url 'about' %}"><i class="fa fa-info-circle"></i> {% trans "About" %}</a></li>
|
||||||
|
<li><a href="{% url 'contact' %}"><i class="fas fa-at"></i> {% trans "Contact" %}</a></li>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% if not request.user.is_authenticated %}
|
{% if not request.user.is_authenticated %}
|
||||||
{% if var_sa %}
|
{% if var_sa %}
|
||||||
|
|
Loading…
Reference in a new issue