8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 15:12:25 +00:00

Merge branch 'personalized_message_mail'

This commit is contained in:
Pierre Cadart 2017-09-09 14:13:45 +00:00
commit f08c853f47
13 changed files with 153 additions and 35 deletions

View file

@ -171,6 +171,46 @@ ldap_host="localhost"
fi fi
TITLE="Hôte pour l'envoi de mail"
email_host=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty)
TITLE="Port du serveur mail"
OPTIONS=(25 "25 (SMTP)"
465 "465 (SMTPS)"
587 "587 (Submission)")
email_port=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
if [ $ldap_is_local == 2 ]
then
TITLE="Cn ldap admin"
ldap_cn=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty)
clear
TITLE="Hote ldap"
ldap_host=$(dialog --title "$TITLE" \
--backtitle "$BACKTITLE" \
--inputbox "$TITLE" $HEIGHT $WIDTH \
2>&1 >/dev/tty)
clear
else
ldap_cn="cn=admin,"
ldap_cn+=$ldap_dn
ldap_host="localhost"
fi
echo "Installation des paquets de base" echo "Installation des paquets de base"
apt-get -y install python3-django python3-dateutil texlive-latex-base texlive-fonts-recommended python3-djangorestframework python3-django-reversion python3-pip libsasl2-dev libldap2-dev libssl-dev apt-get -y install python3-django python3-dateutil texlive-latex-base texlive-fonts-recommended python3-djangorestframework python3-django-reversion python3-pip libsasl2-dev libldap2-dev libssl-dev
pip3 install django-bootstrap3 pip3 install django-bootstrap3
@ -229,6 +269,8 @@ sed -i 's/SUPER_SECRET_LDAP/'"$ldap_password"'/g' re2o/settings_local.py
sed -i 's/ldap_host_ip/'"$ldap_host"'/g' re2o/settings_local.py sed -i 's/ldap_host_ip/'"$ldap_host"'/g' re2o/settings_local.py
sed -i 's/dc=example,dc=org/'"$ldap_dn"'/g' re2o/settings_local.py sed -i 's/dc=example,dc=org/'"$ldap_dn"'/g' re2o/settings_local.py
sed -i 's/example.org/'"$extension_locale"'/g' re2o/settings_local.py sed -i 's/example.org/'"$extension_locale"'/g' re2o/settings_local.py
sed -i 's/MY_EMAIL_HOST/'"$email_host"'/g' re2o/settings_local.py
sed -i 's/MY_EMAIL_PORT/'"$email_port"'/g' re2o/settings_local.py
echo "Application des migrations" echo "Application des migrations"
python3 manage.py migrate python3 manage.py migrate

View file

@ -23,7 +23,7 @@
from django.contrib import admin from django.contrib import admin
from reversion.admin import VersionAdmin from reversion.admin import VersionAdmin
from .models import OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption, Service, AssoOption from .models import OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption, Service, AssoOption, MailMessageOption
class OptionalUserAdmin(VersionAdmin): class OptionalUserAdmin(VersionAdmin):
pass pass
@ -31,7 +31,6 @@ class OptionalUserAdmin(VersionAdmin):
class OptionalTopologieAdmin(VersionAdmin): class OptionalTopologieAdmin(VersionAdmin):
pass pass
class OptionalMachineAdmin(VersionAdmin): class OptionalMachineAdmin(VersionAdmin):
pass pass
@ -44,9 +43,13 @@ class ServiceAdmin(VersionAdmin):
class AssoOptionAdmin(VersionAdmin): class AssoOptionAdmin(VersionAdmin):
pass pass
class MailMessageOptionAdmin(VersionAdmin):
pass
admin.site.register(OptionalUser, OptionalUserAdmin) admin.site.register(OptionalUser, OptionalUserAdmin)
admin.site.register(OptionalMachine, OptionalMachineAdmin) admin.site.register(OptionalMachine, OptionalMachineAdmin)
admin.site.register(OptionalTopologie, OptionalTopologieAdmin) admin.site.register(OptionalTopologie, OptionalTopologieAdmin)
admin.site.register(GeneralOption, GeneralOptionAdmin) admin.site.register(GeneralOption, GeneralOptionAdmin)
admin.site.register(Service, ServiceAdmin) admin.site.register(Service, ServiceAdmin)
admin.site.register(AssoOption, AssoOptionAdmin) admin.site.register(AssoOption, AssoOptionAdmin)
admin.site.register(MailMessageOption, MailMessageOptionAdmin)

View file

@ -22,7 +22,7 @@
from django.forms import ModelForm, Form, ValidationError from django.forms import ModelForm, Form, ValidationError
from django import forms from django import forms
from .models import OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption, AssoOption, Service from .models import OptionalUser, OptionalMachine, OptionalTopologie, GeneralOption, AssoOption, MailMessageOption, Service
from django.db.models import Q from django.db.models import Q
class EditOptionalUserForm(ModelForm): class EditOptionalUserForm(ModelForm):
@ -66,12 +66,36 @@ class EditGeneralOptionForm(ModelForm):
self.fields['search_display_page'].label = 'Resultats affichés dans une recherche' self.fields['search_display_page'].label = 'Resultats affichés dans une recherche'
self.fields['pagination_number'].label = 'Items par page, taille normale (ex users)' self.fields['pagination_number'].label = 'Items par page, taille normale (ex users)'
self.fields['pagination_large_number'].label = 'Items par page, taille élevée (machines)' self.fields['pagination_large_number'].label = 'Items par page, taille élevée (machines)'
self.fields['req_expire_hrs'].label = 'Temps avant expiration du lien de reinitialisation de mot de passe (en heures)'
self.fields['site_name'].label = 'Nom du site web'
self.fields['email_from'].label = 'Adresse mail d\'expedition automatique'
class EditAssoOptionForm(ModelForm): class EditAssoOptionForm(ModelForm):
class Meta: class Meta:
model = AssoOption model = AssoOption
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs):
super(EditAssoOptionForm, self).__init__(*args, **kwargs)
self.fields['name'].label = 'Nom de l\'asso'
self.fields['siret'].label = 'SIRET'
self.fields['adresse1'].label = 'Adresse (ligne 1)'
self.fields['adresse2'].label = 'Adresse (ligne 2)'
self.fields['contact'].label = 'Email de contact'
self.fields['telephone'].label = 'Numéro de téléphone'
self.fields['pseudo'].label = 'Pseudo d\'usage'
self.fields['utilisateur_asso'].label = 'Compte utilisé pour faire les modifications depuis /admin'
class EditMailMessageOptionForm(ModelForm):
class Meta:
model = MailMessageOption
fields = '__all__'
def __init__(self, *args, **kwargs):
super(EditMailMessageOptionForm, self).__init__(*args, **kwargs)
self.fields['welcome_mail_fr'].label = 'Message dans le mail de bienvenue en français'
self.fields['welcome_mail_en'].label = 'Message dans le mail de bienvenue en anglais'
class ServiceForm(ModelForm): class ServiceForm(ModelForm):
class Meta: class Meta:
model = Service model = Service

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-09-08 20:17
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0016_auto_20170902_1520'),
]
operations = [
migrations.CreateModel(
name='MailMessageOption',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('welcome_mail_fr', models.TextField(default='')),
('welcome_mail_en', models.TextField(default='')),
],
),
]

View file

@ -87,3 +87,10 @@ class AssoOption(models.Model):
telephone = models.CharField(max_length=15, default="0000000000") telephone = models.CharField(max_length=15, default="0000000000")
pseudo = models.CharField(default="Asso", max_length=32) pseudo = models.CharField(default="Asso", max_length=32)
utilisateur_asso = models.OneToOneField('users.User', on_delete=models.PROTECT, blank=True, null=True) utilisateur_asso = models.OneToOneField('users.User', on_delete=models.PROTECT, blank=True, null=True)
class MailMessageOption(models.Model):
PRETTY_NAME = "Options de corps de mail"
welcome_mail_fr = models.TextField(default="")
welcome_mail_en = models.TextField(default="")

View file

@ -47,6 +47,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<th>Champ gpg fingerprint</th> <th>Champ gpg fingerprint</th>
<td>{{ useroptions.gpg_fingerprint }}</td> <td>{{ useroptions.gpg_fingerprint }}</td>
{% if useroptions.user_solde %}
<th>Solde négatif</th>
<td>{{ useroptions.solde_negatif }}</td>
{% endif %}
</tr> </tr>
</table> </table>
<h4>Préférences machines</h4> <h4>Préférences machines</h4>
@ -140,7 +144,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr> </tr>
<tr> <tr>
<th>Adresse</th> <th>Adresse</th>
<td>{{ assooptions.adresse1 }} {{ assooptions.adresse2 }}</td> <td>{{ assooptions.adresse1 }}<br>
{{ assooptions.adresse2 }}</td>
<th>Contact mail</th> <th>Contact mail</th>
<td>{{ assooptions.contact }}</td> <td>{{ assooptions.contact }}</td>
</tr> </tr>
@ -155,6 +160,25 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>{{ assooptions.utilisateur_asso }}</td> <td>{{ assooptions.utilisateur_asso }}</td>
</tr> </tr>
</table> </table>
<h4>Messages personalisé dans les mails</h4>
{% if is_bureau %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:edit-options' 'MailMessageOption' %}">
<i class="glyphicon glyphicon-edit"></i>
Editer
</a>
{% endif %}
<p>
</p>
<table class="table table-striped">
<tr>
<th>Mail de bienvenue (Français)</th>
<td>{{ mailmessageoptions.welcome_mail_fr | safe }}</td>
</tr>
<tr>
<th>Mail de bienvenue (Anglais)</th>
<td>{{ mailmessageoptions.welcome_mail_en | safe }}</td>
</tr>
</table>
<h2>Liste des services page d'accueil</h2> <h2>Liste des services page d'accueil</h2>
{% if is_infra %} {% if is_infra %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-services' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un service</a> <a class="btn btn-primary btn-sm" role="button" href="{% url 'preferences:add-services' %}"><i class="glyphicon glyphicon-plus"></i> Ajouter un service</a>

View file

@ -31,6 +31,7 @@ urlpatterns = [
url(r'^edit_options/(?P<section>OptionalTopologie)$', views.edit_options, name='edit-options'), url(r'^edit_options/(?P<section>OptionalTopologie)$', views.edit_options, name='edit-options'),
url(r'^edit_options/(?P<section>GeneralOption)$', views.edit_options, name='edit-options'), url(r'^edit_options/(?P<section>GeneralOption)$', views.edit_options, name='edit-options'),
url(r'^edit_options/(?P<section>AssoOption)$', views.edit_options, name='edit-options'), url(r'^edit_options/(?P<section>AssoOption)$', views.edit_options, name='edit-options'),
url(r'^edit_options/(?P<section>MailMessageOption)$', views.edit_options, name='edit-options'),
url(r'^add_services/$', views.add_services, name='add-services'), url(r'^add_services/$', views.add_services, name='add-services'),
url(r'^edit_services/(?P<servicesid>[0-9]+)$', views.edit_services, name='edit-services'), url(r'^edit_services/(?P<servicesid>[0-9]+)$', views.edit_services, name='edit-services'),
url(r'^del_services/$', views.del_services, name='del-services'), url(r'^del_services/$', views.del_services, name='del-services'),

View file

@ -43,7 +43,7 @@ from reversion.models import Version
from reversion import revisions as reversion from reversion import revisions as reversion
from .forms import ServiceForm, DelServiceForm from .forms import ServiceForm, DelServiceForm
from .models import Service, OptionalUser, OptionalMachine, AssoOption, GeneralOption, OptionalTopologie from .models import Service, OptionalUser, OptionalMachine, AssoOption, MailMessageOption, GeneralOption, OptionalTopologie
from . import models from . import models
from . import forms from . import forms
@ -60,9 +60,10 @@ def display_options(request):
machineoptions, created = OptionalMachine.objects.get_or_create() machineoptions, created = OptionalMachine.objects.get_or_create()
topologieoptions, created = OptionalTopologie.objects.get_or_create() topologieoptions, created = OptionalTopologie.objects.get_or_create()
generaloptions, created = GeneralOption.objects.get_or_create() generaloptions, created = GeneralOption.objects.get_or_create()
assooptions, crated = AssoOption.objects.get_or_create() assooptions, created = AssoOption.objects.get_or_create()
mailmessageoptions, created = MailMessageOption.objects.get_or_create()
service_list = Service.objects.all() service_list = Service.objects.all()
return form({'useroptions': useroptions, 'machineoptions': machineoptions, 'topologieoptions': topologieoptions, 'generaloptions': generaloptions, 'assooptions' : assooptions, 'service_list':service_list}, 'preferences/display_preferences.html', request) return form({'useroptions': useroptions, 'machineoptions': machineoptions, 'topologieoptions': topologieoptions, 'generaloptions': generaloptions, 'assooptions' : assooptions, 'mailmessageoptions' : mailmessageoptions, 'service_list':service_list}, 'preferences/display_preferences.html', request)
@login_required @login_required
@permission_required('admin') @permission_required('admin')

View file

@ -61,6 +61,9 @@ SESSION_COOKIE_AGE = 60 * 60 * 3
LOGO_PATH = "static_files/logo.png" LOGO_PATH = "static_files/logo.png"
EMAIL_HOST = 'MY_EMAIL_HOST'
EMAIL_PORT = MY_EMAIL_PORT
# Reglages pour la bdd ldap # Reglages pour la bdd ldap
LDAP = { LDAP = {
'base_user_dn' : 'cn=Utilisateurs,dc=example,dc=org', 'base_user_dn' : 'cn=Utilisateurs,dc=example,dc=org',

View file

@ -47,7 +47,7 @@ from django.core.validators import MinLengthValidator
from topologie.models import Room from topologie.models import Room
from cotisations.models import Cotisation, Facture, Paiement, Vente from cotisations.models import Cotisation, Facture, Paiement, Vente
from machines.models import Interface, Machine, regen from machines.models import Interface, Machine, regen
from preferences.models import GeneralOption, AssoOption, OptionalUser from preferences.models import GeneralOption, AssoOption, OptionalUser, MailMessageOption
now = timezone.now() now = timezone.now()
@ -415,15 +415,18 @@ class User(AbstractBaseUser):
def notif_inscription(self): def notif_inscription(self):
""" Prend en argument un objet user, envoie un mail de bienvenue """ """ Prend en argument un objet user, envoie un mail de bienvenue """
t = loader.get_template('users/email_welcome') t = loader.get_template('users/email_welcome')
options, created = AssoOption.objects.get_or_create() assooptions, created = AssoOption.objects.get_or_create()
mailmessageoptions, created = MailMessageOption.objects.get_or_create()
general_options, created = GeneralOption.objects.get_or_create() general_options, created = GeneralOption.objects.get_or_create()
c = Context({ c = Context({
'nom': str(self.name) + ' ' + str(self.surname), 'nom': str(self.name) + ' ' + str(self.surname),
'asso_name': options.name, 'asso_name': assooptions.name,
'asso_email': options.contact, 'asso_email': assooptions.contact,
'welcome_mail_fr' : mailmessageoptions.welcome_mail_fr,
'welcome_mail_en' : mailmessageoptions.welcome_mail_en,
'pseudo':self.pseudo, 'pseudo':self.pseudo,
}) })
send_mail('Bienvenue au %(name)s / Welcome to %(name)s' % {'name': options.name }, '', send_mail('Bienvenue au %(name)s / Welcome to %(name)s' % {'name': assooptions.name }, '',
general_options.email_from, [self.email], html_message=t.render(c)) general_options.email_from, [self.email], html_message=t.render(c))
return return

View file

@ -1,8 +1,8 @@
Bonjour {{name}}, Bonjour {{name}},
Vous avez été banni par un administrateur du {{ asso_name }} en raison de {{raison}}. Vous n'avez plus accès au réseau jusqu'au {{date_end}}. Vous avez été banni par un administrateur de {{ asso_name }} en raison de {{raison}}. Vous n'avez plus accès au réseau jusqu'au {{date_end}}.
Pour de plus amples informations, rendez-vous à l'accueil du {{ asso_name }}. Pour de plus amples informations, rendez-vous à l'accueil de {{ asso_name }}.
Cordialement, Cordialement,
L'équipe du {{ asso_name }}. L'équipe de {{ asso_name }}.

View file

@ -12,7 +12,7 @@ Ce lien expirera dans {{ expire_in }}.
Cordialement, Cordialement,
L'équipe de {{ asso }} {{ asso_mail }}. L'équipe de {{ asso }} (contact : {{ asso_mail }}).
---------------------- ----------------------
@ -30,4 +30,4 @@ any other question.
Thanks Thanks
The team of {{ asso }} The team of {{ asso }} (contact : {{ asso_mail }}).

View file

@ -1,19 +1,12 @@
<p>Bonjour {{nom}} !</p> <p>Bonjour {{nom}} !</p>
<p>Vous êtes maintenant adhérent du {{asso_name}} ! Nous sommes ravis de vous accueillir<br> <p>Vous êtes maintenant adhérent de {{asso_name}} ! Nous sommes ravis de vous accueillir dans l'association.</p>
dans l'association. Outre l'accès à Internet, vous pourrez participer aux activités<br>
que nous proposons et profiter des services mis en place. Ceux-ci sont à découvrir<br>
sur le site <a href="https://re2o.rezometz.org">Re2o</a> qui vous permet aussi de gérer vos informations personnelles.</p>
<p>Si vous n'avez pas été enregistré directement par un élève sur place vous devez suivre ce guide expliquant la procédure de connexion (vous devriez commencer avant d'arriver afin d'avoir internet tout de suite) : <a href="https://slides.rezometz.org/welcome"> https://slides.rezometz.org/welcome </a></p>
<p>Votre pseudo est : {{pseudo}}</p> <p>Votre pseudo est : {{pseudo}}</p>
<p>Le {{asso_name}} recrute ! Nous sommes passionnés (et bénévoles), alors si vous êtes intéressé<br> {{welcome_mail_fr|safe}}
de près ou de loin pour nous aider, n'hésitez pas !</p>
<p>Pour nous faire part de toute remarque, suggestion ou problème vous pouvez nous<br> <p>Pour nous faire part de toute remarque, suggestion ou problème vous pouvez nous envoyer un mail à {{asso_email}}.</p>
envoyer un mail à {{asso_email}}.</p>
<p>À bientôt,<br> <p>À bientôt,<br>
L'équipe de {{asso_name}}.</p> L'équipe de {{asso_name}}.</p>
@ -22,18 +15,12 @@ L'équipe de {{asso_name}}.</p>
<p>Welcome to the {{asso_name}} !</p> <p>Welcome to the {{asso_name}} !</p>
<p>We are the association that provides an internet acces in the dorm of ALOES</p>
<p>If you have never been in contact with a member of the association you need to follow this guide explaining how to connect (even if you are not in the dorm yet) : <a href="https://slides.rezometz.org/welcome">https://slides.rezometz.org/welcome</a></p>
<p>Your username is : {{pseudo}}<p> <p>Your username is : {{pseudo}}<p>
<p>As a member of the association, not only can you access to the Internet but also a<br> {{welcome_mail_en|safe}}
variety of services that you can discover on the website <a href="https://re2o.rezometz.org">Re2o</a> (log in using your<br>
credentials).</p>
<p>For any information, suggestion or problem, you can contact us via email at<br> <p>For any information, suggestion or problem, you can contact us via email at<br>
{{asso_email}}.</p> {{asso_email}}.</p>
<p>Regards,<br> <p>Regards,<br>
The (voluntary) {{asso_name}} team.</p> The {{asso_name}} team.</p>