diff --git a/install_re2o.sh b/install_re2o.sh index 9100bc15..aff54cb0 100755 --- a/install_re2o.sh +++ b/install_re2o.sh @@ -171,6 +171,46 @@ ldap_host="localhost" 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" 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 @@ -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/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/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" python3 manage.py migrate diff --git a/preferences/admin.py b/preferences/admin.py index d4c41e62..867596fe 100644 --- a/preferences/admin.py +++ b/preferences/admin.py @@ -23,7 +23,7 @@ from django.contrib import admin 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): pass @@ -31,7 +31,6 @@ class OptionalUserAdmin(VersionAdmin): class OptionalTopologieAdmin(VersionAdmin): pass - class OptionalMachineAdmin(VersionAdmin): pass @@ -44,9 +43,13 @@ class ServiceAdmin(VersionAdmin): class AssoOptionAdmin(VersionAdmin): pass +class MailMessageOptionAdmin(VersionAdmin): + pass + admin.site.register(OptionalUser, OptionalUserAdmin) admin.site.register(OptionalMachine, OptionalMachineAdmin) admin.site.register(OptionalTopologie, OptionalTopologieAdmin) admin.site.register(GeneralOption, GeneralOptionAdmin) admin.site.register(Service, ServiceAdmin) admin.site.register(AssoOption, AssoOptionAdmin) +admin.site.register(MailMessageOption, MailMessageOptionAdmin) diff --git a/preferences/forms.py b/preferences/forms.py index 37e9c7ea..ca2df893 100644 --- a/preferences/forms.py +++ b/preferences/forms.py @@ -22,7 +22,7 @@ from django.forms import ModelForm, Form, ValidationError 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 class EditOptionalUserForm(ModelForm): @@ -66,12 +66,36 @@ class EditGeneralOptionForm(ModelForm): 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_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 Meta: model = AssoOption 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 Meta: model = Service diff --git a/preferences/migrations/0017_mailmessageoption.py b/preferences/migrations/0017_mailmessageoption.py new file mode 100644 index 00000000..31fb145c --- /dev/null +++ b/preferences/migrations/0017_mailmessageoption.py @@ -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='')), + ], + ), + ] diff --git a/preferences/models.py b/preferences/models.py index 92822190..b56faf3d 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -87,3 +87,10 @@ class AssoOption(models.Model): telephone = models.CharField(max_length=15, default="0000000000") pseudo = models.CharField(default="Asso", max_length=32) 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="") + diff --git a/preferences/templates/preferences/display_preferences.html b/preferences/templates/preferences/display_preferences.html index 394a4714..d96f4ed7 100644 --- a/preferences/templates/preferences/display_preferences.html +++ b/preferences/templates/preferences/display_preferences.html @@ -47,6 +47,10 @@ with this program; if not, write to the Free Software Foundation, Inc., Champ gpg fingerprint {{ useroptions.gpg_fingerprint }} + {% if useroptions.user_solde %} + Solde négatif + {{ useroptions.solde_negatif }} + {% endif %}

Préférences machines

@@ -140,7 +144,8 @@ with this program; if not, write to the Free Software Foundation, Inc., Adresse - {{ assooptions.adresse1 }} {{ assooptions.adresse2 }} + {{ assooptions.adresse1 }}
+ {{ assooptions.adresse2 }} Contact mail {{ assooptions.contact }} @@ -155,6 +160,25 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ assooptions.utilisateur_asso }} +

Messages personalisé dans les mails

+ {% if is_bureau %} + + + Editer + + {% endif %} +

+

+ + + + + + + + + +
Mail de bienvenue (Français){{ mailmessageoptions.welcome_mail_fr | safe }}
Mail de bienvenue (Anglais){{ mailmessageoptions.welcome_mail_en | safe }}

Liste des services page d'accueil

{% if is_infra %} Ajouter un service diff --git a/preferences/urls.py b/preferences/urls.py index dd9ccd8b..624971d8 100644 --- a/preferences/urls.py +++ b/preferences/urls.py @@ -31,6 +31,7 @@ urlpatterns = [ url(r'^edit_options/(?P
OptionalTopologie)$', views.edit_options, name='edit-options'), url(r'^edit_options/(?P
GeneralOption)$', views.edit_options, name='edit-options'), url(r'^edit_options/(?P
AssoOption)$', views.edit_options, name='edit-options'), + url(r'^edit_options/(?P
MailMessageOption)$', views.edit_options, name='edit-options'), url(r'^add_services/$', views.add_services, name='add-services'), url(r'^edit_services/(?P[0-9]+)$', views.edit_services, name='edit-services'), url(r'^del_services/$', views.del_services, name='del-services'), diff --git a/preferences/views.py b/preferences/views.py index dc29aee2..66ecd101 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -43,7 +43,7 @@ from reversion.models import Version from reversion import revisions as reversion 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 forms @@ -60,9 +60,10 @@ def display_options(request): machineoptions, created = OptionalMachine.objects.get_or_create() topologieoptions, created = OptionalTopologie.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() - 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 @permission_required('admin') diff --git a/re2o/settings_local.example.py b/re2o/settings_local.example.py index 6110bc02..466c953d 100644 --- a/re2o/settings_local.example.py +++ b/re2o/settings_local.example.py @@ -61,6 +61,9 @@ SESSION_COOKIE_AGE = 60 * 60 * 3 LOGO_PATH = "static_files/logo.png" +EMAIL_HOST = 'MY_EMAIL_HOST' +EMAIL_PORT = MY_EMAIL_PORT + # Reglages pour la bdd ldap LDAP = { 'base_user_dn' : 'cn=Utilisateurs,dc=example,dc=org', diff --git a/users/models.py b/users/models.py index 34f20fdc..4034a2f3 100644 --- a/users/models.py +++ b/users/models.py @@ -47,7 +47,7 @@ from django.core.validators import MinLengthValidator from topologie.models import Room from cotisations.models import Cotisation, Facture, Paiement, Vente 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() @@ -415,15 +415,18 @@ class User(AbstractBaseUser): def notif_inscription(self): """ Prend en argument un objet user, envoie un mail de bienvenue """ 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() c = Context({ 'nom': str(self.name) + ' ' + str(self.surname), - 'asso_name': options.name, - 'asso_email': options.contact, + 'asso_name': assooptions.name, + 'asso_email': assooptions.contact, + 'welcome_mail_fr' : mailmessageoptions.welcome_mail_fr, + 'welcome_mail_en' : mailmessageoptions.welcome_mail_en, '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)) return diff --git a/users/templates/users/email_ban_notif b/users/templates/users/email_ban_notif index 67cb4e14..f61cd840 100644 --- a/users/templates/users/email_ban_notif +++ b/users/templates/users/email_ban_notif @@ -1,8 +1,8 @@ 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, - L'équipe du {{ asso_name }}. + L'équipe de {{ asso_name }}. diff --git a/users/templates/users/email_passwd_request b/users/templates/users/email_passwd_request index cc8df186..2a648d55 100644 --- a/users/templates/users/email_passwd_request +++ b/users/templates/users/email_passwd_request @@ -12,7 +12,7 @@ Ce lien expirera dans {{ expire_in }}. Cordialement, -L'équipe de {{ asso }} {{ asso_mail }}. +L'équipe de {{ asso }} (contact : {{ asso_mail }}). ---------------------- @@ -30,4 +30,4 @@ any other question. Thanks -The team of {{ asso }} +The team of {{ asso }} (contact : {{ asso_mail }}). diff --git a/users/templates/users/email_welcome b/users/templates/users/email_welcome index c9d3b570..690f69d1 100644 --- a/users/templates/users/email_welcome +++ b/users/templates/users/email_welcome @@ -1,19 +1,12 @@

Bonjour {{nom}} !

-

Vous êtes maintenant adhérent du {{asso_name}} ! Nous sommes ravis de vous accueillir
-dans l'association. Outre l'accès à Internet, vous pourrez participer aux activités
-que nous proposons et profiter des services mis en place. Ceux-ci sont à découvrir
-sur le site Re2o qui vous permet aussi de gérer vos informations personnelles.

- -

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) : https://slides.rezometz.org/welcome

+

Vous êtes maintenant adhérent de {{asso_name}} ! Nous sommes ravis de vous accueillir dans l'association.

Votre pseudo est : {{pseudo}}

-

Le {{asso_name}} recrute ! Nous sommes passionnés (et bénévoles), alors si vous êtes intéressé
-de près ou de loin pour nous aider, n'hésitez pas !

+{{welcome_mail_fr|safe}} -

Pour nous faire part de toute remarque, suggestion ou problème vous pouvez nous
-envoyer un mail à {{asso_email}}.

+

Pour nous faire part de toute remarque, suggestion ou problème vous pouvez nous envoyer un mail à {{asso_email}}.

À bientôt,
L'équipe de {{asso_name}}.

@@ -22,18 +15,12 @@ L'équipe de {{asso_name}}.

Welcome to the {{asso_name}} !

-

We are the association that provides an internet acces in the dorm of ALOES

- -

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) : https://slides.rezometz.org/welcome

-

Your username is : {{pseudo}}

-

As a member of the association, not only can you access to the Internet but also a
-variety of services that you can discover on the website Re2o (log in using your
-credentials).

+{{welcome_mail_en|safe}}

For any information, suggestion or problem, you can contact us via email at
{{asso_email}}.

Regards,
-The (voluntary) {{asso_name}} team.

+The {{asso_name}} team.