mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-24 16:03:47 +00:00
Reglages nom du site et emailfrom dans preferences
This commit is contained in:
parent
0719e89a8b
commit
7aa69ab60f
11 changed files with 107 additions and 29 deletions
|
@ -33,8 +33,6 @@ import re
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from re2o.settings import MAIN_EXTENSION
|
|
||||||
|
|
||||||
|
|
||||||
class Machine(models.Model):
|
class Machine(models.Model):
|
||||||
""" Class définissant une machine, object parent user, objets fils interfaces"""
|
""" Class définissant une machine, object parent user, objets fils interfaces"""
|
||||||
|
|
20
preferences/migrations/0012_generaloption_req_expire_hrs.py
Normal file
20
preferences/migrations/0012_generaloption_req_expire_hrs.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2017-08-26 13:30
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0011_auto_20170825_2307'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='generaloption',
|
||||||
|
name='req_expire_hrs',
|
||||||
|
field=models.IntegerField(default=48),
|
||||||
|
),
|
||||||
|
]
|
20
preferences/migrations/0013_generaloption_site_name.py
Normal file
20
preferences/migrations/0013_generaloption_site_name.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2017-08-26 13:40
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0012_generaloption_req_expire_hrs'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='generaloption',
|
||||||
|
name='site_name',
|
||||||
|
field=models.CharField(default='Re2o', max_length=32),
|
||||||
|
),
|
||||||
|
]
|
20
preferences/migrations/0014_generaloption_email_from.py
Normal file
20
preferences/migrations/0014_generaloption_email_from.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2017-08-26 13:58
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('preferences', '0013_generaloption_site_name'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='generaloption',
|
||||||
|
name='email_from',
|
||||||
|
field=models.EmailField(default='www-data@serveur.net', max_length=254),
|
||||||
|
),
|
||||||
|
]
|
|
@ -56,6 +56,9 @@ class GeneralOption(models.Model):
|
||||||
search_display_page = models.IntegerField(default=15)
|
search_display_page = models.IntegerField(default=15)
|
||||||
pagination_number = models.IntegerField(default=25)
|
pagination_number = models.IntegerField(default=25)
|
||||||
pagination_large_number = models.IntegerField(default=8)
|
pagination_large_number = models.IntegerField(default=8)
|
||||||
|
req_expire_hrs = models.IntegerField(default=48)
|
||||||
|
site_name = models.CharField(max_length=32, default="Re2o")
|
||||||
|
email_from = models.EmailField(default="www-data@serveur.net")
|
||||||
|
|
||||||
class Service(models.Model):
|
class Service(models.Model):
|
||||||
name = models.CharField(max_length=32)
|
name = models.CharField(max_length=32)
|
||||||
|
|
|
@ -97,6 +97,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
<tr>
|
||||||
|
<th>Nom du site web</th>
|
||||||
|
<td>{{ generaloptions.site_name }}</td>
|
||||||
|
<th>Adresse mail d'expedition automatique</th>
|
||||||
|
<td>{{ generaloptions.email_from }}</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Affichage de résultats dans le champ de recherche</th>
|
<th>Affichage de résultats dans le champ de recherche</th>
|
||||||
<td>{{ generaloptions.search_display_page }}</td>
|
<td>{{ generaloptions.search_display_page }}</td>
|
||||||
|
@ -106,6 +112,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<tr>
|
<tr>
|
||||||
<th>Nombre d'items affichés en liste (taille élevée)</th>
|
<th>Nombre d'items affichés en liste (taille élevée)</th>
|
||||||
<td>{{ generaloptions.pagination_large_number }}</td>
|
<td>{{ generaloptions.pagination_large_number }}</td>
|
||||||
|
<th>Temps avant expiration du lien de reinitialisation de mot de passe (en heures)</th>
|
||||||
|
<td>{{ generaloptions.req_expire_hrs }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h4>Données de l'association</h4>
|
<h4>Données de l'association</h4>
|
||||||
|
|
|
@ -21,9 +21,10 @@
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
from machines.models import Interface, Machine
|
from machines.models import Interface, Machine
|
||||||
from .settings import SITE_NAME
|
from preferences.models import GeneralOption
|
||||||
|
|
||||||
def context_user(request):
|
def context_user(request):
|
||||||
|
general_options, created = GeneralOption.objects.get_or_create()
|
||||||
user = request.user
|
user = request.user
|
||||||
if user.is_authenticated():
|
if user.is_authenticated():
|
||||||
interfaces = user.user_interfaces()
|
interfaces = user.user_interfaces()
|
||||||
|
@ -50,5 +51,5 @@ def context_user(request):
|
||||||
'is_infra': is_infra,
|
'is_infra': is_infra,
|
||||||
'is_admin' : is_admin,
|
'is_admin' : is_admin,
|
||||||
'interfaces': interfaces,
|
'interfaces': interfaces,
|
||||||
'site_name': SITE_NAME,
|
'site_name': general_options.site_name,
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,23 +59,8 @@ CSRF_COOKIE_HTTPONLY = True
|
||||||
X_FRAME_OPTIONS = 'DENY'
|
X_FRAME_OPTIONS = 'DENY'
|
||||||
SESSION_COOKIE_AGE = 60 * 60 * 3
|
SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||||
|
|
||||||
# Association information
|
|
||||||
|
|
||||||
SITE_NAME = "Re2o.rez"
|
|
||||||
|
|
||||||
# Main extension used in asso
|
|
||||||
MAIN_EXTENSION = ".rez"
|
|
||||||
|
|
||||||
LOGO_PATH = "static_files/logo.png"
|
LOGO_PATH = "static_files/logo.png"
|
||||||
|
|
||||||
# Number of hours a token remains valid after having been created. Numeric and string
|
|
||||||
# versions should have the same meaning.
|
|
||||||
REQ_EXPIRE_HRS = 48
|
|
||||||
REQ_EXPIRE_STR = '48 heures'
|
|
||||||
|
|
||||||
# Email `From` field
|
|
||||||
EMAIL_FROM = 'www-data@serveur.net'
|
|
||||||
|
|
||||||
EMAIL_HOST = 'smtp.example.org'
|
EMAIL_HOST = 'smtp.example.org'
|
||||||
|
|
||||||
# Reglages pour la bdd ldap
|
# Reglages pour la bdd ldap
|
||||||
|
|
20
topologie/migrations/0023_auto_20170826_1530.py
Normal file
20
topologie/migrations/0023_auto_20170826_1530.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.7 on 2017-08-26 13:30
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('topologie', '0022_auto_20161211_1622'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='port',
|
||||||
|
name='radius',
|
||||||
|
field=models.CharField(choices=[('NO', 'NO'), ('STRICT', 'STRICT'), ('BLOQ', 'BLOQ'), ('COMMON', 'COMMON'), ('3', '3'), ('7', '7'), ('8', '8'), ('13', '13'), ('20', '20'), ('42', '42'), ('69', '69')], default='NO', max_length=32),
|
||||||
|
),
|
||||||
|
]
|
|
@ -33,7 +33,7 @@ from django.db import transaction
|
||||||
import ldapdb.models
|
import ldapdb.models
|
||||||
import ldapdb.models.fields
|
import ldapdb.models.fields
|
||||||
|
|
||||||
from re2o.settings import RIGHTS_LINK, REQ_EXPIRE_HRS, LDAP, GID_RANGES,UID_RANGES
|
from re2o.settings import RIGHTS_LINK, LDAP, GID_RANGES,UID_RANGES
|
||||||
import re, uuid
|
import re, uuid
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
@ -44,7 +44,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
|
from machines.models import Interface, Machine
|
||||||
from preferences.models import OptionalUser
|
from preferences.models import GeneralOption, OptionalUser
|
||||||
|
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
|
|
||||||
|
@ -622,8 +622,9 @@ class Request(models.Model):
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if not self.expires_at:
|
if not self.expires_at:
|
||||||
|
options, created = GeneralOption.objects.get_or_create()
|
||||||
self.expires_at = timezone.now() \
|
self.expires_at = timezone.now() \
|
||||||
+ datetime.timedelta(hours=REQ_EXPIRE_HRS)
|
+ datetime.timedelta(hours=options.req_expire_hrs)
|
||||||
if not self.token:
|
if not self.token:
|
||||||
self.token = str(uuid.uuid4()).replace('-', '') # remove hyphens
|
self.token = str(uuid.uuid4()).replace('-', '') # remove hyphens
|
||||||
super(Request, self).save()
|
super(Request, self).save()
|
||||||
|
|
|
@ -47,7 +47,6 @@ from users.forms import MassArchiveForm, PassForm, ResetPasswordForm
|
||||||
from preferences.models import OptionalUser, AssoOption, GeneralOption
|
from preferences.models import OptionalUser, AssoOption, GeneralOption
|
||||||
|
|
||||||
from re2o.login import hashNT
|
from re2o.login import hashNT
|
||||||
from re2o.settings import REQ_EXPIRE_STR, EMAIL_FROM, SITE_NAME
|
|
||||||
|
|
||||||
|
|
||||||
def form(ctx, template, request):
|
def form(ctx, template, request):
|
||||||
|
@ -74,21 +73,23 @@ def password_change_action(u_form, user, request, req=False):
|
||||||
def reset_passwd_mail(req, request):
|
def reset_passwd_mail(req, request):
|
||||||
""" Prend en argument un request, envoie un mail de réinitialisation de mot de pass """
|
""" Prend en argument un request, envoie un mail de réinitialisation de mot de pass """
|
||||||
t = loader.get_template('users/email_passwd_request')
|
t = loader.get_template('users/email_passwd_request')
|
||||||
options, created = AssoOption.objects.get_or_create()
|
options, created = AssoOption.objects.get_or_create()
|
||||||
|
general_options, created = GeneralOption.objects.get_or_create()
|
||||||
c = {
|
c = {
|
||||||
'name': str(req.user.name) + ' ' + str(req.user.surname),
|
'name': str(req.user.name) + ' ' + str(req.user.surname),
|
||||||
'asso': options.name,
|
'asso': options.name,
|
||||||
'asso_mail': options.contact,
|
'asso_mail': options.contact,
|
||||||
'site_name': SITE_NAME,
|
'site_name': general_options.site_name,
|
||||||
'url': request.build_absolute_uri(
|
'url': request.build_absolute_uri(
|
||||||
reverse('users:process', kwargs={'token': req.token})),
|
reverse('users:process', kwargs={'token': req.token})),
|
||||||
'expire_in': REQ_EXPIRE_STR,
|
'expire_in': str(general_options.req_expire_hrs) + ' heures',
|
||||||
}
|
}
|
||||||
send_mail('Changement de mot de passe du Rézo Metz / Password renewal for Rézo Metz', t.render(c),
|
send_mail('Changement de mot de passe du Rézo Metz / Password renewal for Rézo Metz', t.render(c),
|
||||||
EMAIL_FROM, [req.user.email], fail_silently=False)
|
general_options.email_from, [req.user.email], fail_silently=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
def notif_ban(ban):
|
def notif_ban(ban):
|
||||||
|
general_options, created = GeneralOption.objects.get_or_create()
|
||||||
""" Prend en argument un objet ban, envoie un mail de notification """
|
""" Prend en argument un objet ban, envoie un mail de notification """
|
||||||
t = loader.get_template('users/email_ban_notif')
|
t = loader.get_template('users/email_ban_notif')
|
||||||
c = Context({
|
c = Context({
|
||||||
|
@ -97,13 +98,14 @@ def notif_ban(ban):
|
||||||
'date_end': ban.date_end,
|
'date_end': ban.date_end,
|
||||||
})
|
})
|
||||||
send_mail('Deconnexion disciplinaire', t.render(c),
|
send_mail('Deconnexion disciplinaire', t.render(c),
|
||||||
EMAIL_FROM, [ban.user.email], fail_silently=False)
|
general_options.email_from, [ban.user.email], fail_silently=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
def notif_inscription(user):
|
def notif_inscription(user):
|
||||||
""" 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()
|
options, created = AssoOption.objects.get_or_create()
|
||||||
|
general_options, created = GeneralOption.objects.get_or_create()
|
||||||
c = Context({
|
c = Context({
|
||||||
'nom': str(user.name) + ' ' + str(user.surname),
|
'nom': str(user.name) + ' ' + str(user.surname),
|
||||||
'asso_name': options.name,
|
'asso_name': options.name,
|
||||||
|
@ -111,7 +113,7 @@ def notif_inscription(user):
|
||||||
'pseudo':user.pseudo,
|
'pseudo':user.pseudo,
|
||||||
})
|
})
|
||||||
send_mail('Bienvenue au Rézo / Welcome to Rézo Metz', '',
|
send_mail('Bienvenue au Rézo / Welcome to Rézo Metz', '',
|
||||||
EMAIL_FROM, [user.email], html_message=t.render(c))
|
general_options.email_from, [user.email], html_message=t.render(c))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue