mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
Merge branch 'buster_ready' into 'dev'
Buster ready See merge request federez/re2o!430
This commit is contained in:
commit
41cbd572c0
9 changed files with 37 additions and 29 deletions
|
@ -5,6 +5,7 @@ texlive-fonts-recommended
|
||||||
python3-djangorestframework
|
python3-djangorestframework
|
||||||
python3-django-reversion
|
python3-django-reversion
|
||||||
python3-pip
|
python3-pip
|
||||||
|
python3-pil
|
||||||
libsasl2-dev libldap2-dev
|
libsasl2-dev libldap2-dev
|
||||||
libssl-dev
|
libssl-dev
|
||||||
python3-crypto
|
python3-crypto
|
||||||
|
|
|
@ -33,7 +33,6 @@ from datetime import datetime
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.template import Context
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
|
@ -105,7 +104,7 @@ def create_pdf(template, ctx={}):
|
||||||
Returns:
|
Returns:
|
||||||
The content of the temporary PDF file generated.
|
The content of the temporary PDF file generated.
|
||||||
"""
|
"""
|
||||||
context = Context(ctx)
|
context = ctx
|
||||||
template = get_template(template)
|
template = get_template(template)
|
||||||
rendered_tpl = template.render(context).encode('utf-8')
|
rendered_tpl = template.render(context).encode('utf-8')
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ install_database() {
|
||||||
if [ "$engine_type" == 1 ]; then
|
if [ "$engine_type" == 1 ]; then
|
||||||
|
|
||||||
echo "Installing MySQL client ..."
|
echo "Installing MySQL client ..."
|
||||||
apt-get -y install python3-mysqldb mysql-client
|
apt-get -y install python3-mysqldb default-mysql-client
|
||||||
echo "Installing MySQL client: Done"
|
echo "Installing MySQL client: Done"
|
||||||
|
|
||||||
mysql_command="CREATE DATABASE $db_name collate='utf8_general_ci';
|
mysql_command="CREATE DATABASE $db_name collate='utf8_general_ci';
|
||||||
|
@ -113,7 +113,7 @@ install_database() {
|
||||||
|
|
||||||
if [ "$local_setup" == 1 ]; then
|
if [ "$local_setup" == 1 ]; then
|
||||||
echo "Setting up local MySQL server ..."
|
echo "Setting up local MySQL server ..."
|
||||||
apt-get -y install mysql-server
|
apt-get -y install default-mysql-server
|
||||||
mysql -u root --execute="$mysql_command"
|
mysql -u root --execute="$mysql_command"
|
||||||
echo "Setting up local MySQL server: Done"
|
echo "Setting up local MySQL server: Done"
|
||||||
else
|
else
|
||||||
|
@ -763,8 +763,9 @@ main_function() {
|
||||||
echo " * {help} ---------- Display this quick usage documentation"
|
echo " * {help} ---------- Display this quick usage documentation"
|
||||||
echo " * {setup} --------- Launch the full interactive guide to setup entirely"
|
echo " * {setup} --------- Launch the full interactive guide to setup entirely"
|
||||||
echo " re2o from scratch"
|
echo " re2o from scratch"
|
||||||
echo " * {update} -------- Collect frontend statics, install the missing APT and copy LaTeX templates files"
|
echo " * {update} -------- Collect frontend statics, install the missing APT"
|
||||||
echo " and pip packages and apply the migrations to the DB"
|
echo " and pip packages, copy LaTeX templates files"
|
||||||
|
echo " and apply the migrations to the DB"
|
||||||
echo " * {update-django} - Apply Django migration and collect frontend statics"
|
echo " * {update-django} - Apply Django migration and collect frontend statics"
|
||||||
echo " * {copy-template-files} - Copy LaTeX templates files to media/templates"
|
echo " * {copy-template-files} - Copy LaTeX templates files to media/templates"
|
||||||
echo " * {update-packages} Install the missing APT and pip packages"
|
echo " * {update-packages} Install the missing APT and pip packages"
|
||||||
|
@ -840,7 +841,7 @@ main_function() {
|
||||||
db_username="re2o"
|
db_username="re2o"
|
||||||
fi
|
fi
|
||||||
install_database "$db_engine_type" 1 "$db_name" "$db_username" "$db_password"
|
install_database "$db_engine_type" 1 "$db_name" "$db_username" "$db_password"
|
||||||
update-django
|
update_django
|
||||||
else
|
else
|
||||||
echo "Invalid arguments !"
|
echo "Invalid arguments !"
|
||||||
echo "Usage: install_re2o setup-db <db_password> [<db_engine_type>] [<db_name>] [<db_username>]"
|
echo "Usage: install_re2o setup-db <db_password> [<db_engine_type>] [<db_name>] [<db_username>]"
|
||||||
|
|
13
re2o/acl.py
13
re2o/acl.py
|
@ -158,10 +158,15 @@ ModelC)
|
||||||
messages.error(
|
messages.error(
|
||||||
request, msg or _("You don't have the right to access"
|
request, msg or _("You don't have the right to access"
|
||||||
" this menu."))
|
" this menu."))
|
||||||
return redirect(reverse(
|
if request.user.id is not None:
|
||||||
'users:profil',
|
return redirect(reverse(
|
||||||
kwargs={'userid': str(request.user.id)}
|
'users:profil',
|
||||||
))
|
kwargs={'userid': str(request.user.id)}
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
return redirect(reverse(
|
||||||
|
'index',
|
||||||
|
))
|
||||||
return view(request, *chain(instances, args), **kwargs)
|
return view(request, *chain(instances, args), **kwargs)
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorator
|
return decorator
|
||||||
|
|
|
@ -232,7 +232,7 @@ class SSHAPasswordHasher(hashers.BasePasswordHasher):
|
||||||
class RecryptBackend(ModelBackend):
|
class RecryptBackend(ModelBackend):
|
||||||
def authenticate(self, username=None, password=None):
|
def authenticate(self, username=None, password=None):
|
||||||
# we obtain from the classical auth backend the user
|
# we obtain from the classical auth backend the user
|
||||||
user = super(RecryptBackend, self).authenticate(username, password)
|
user = super(RecryptBackend, self).authenticate(None, username, password)
|
||||||
if user:
|
if user:
|
||||||
if not(user.pwd_ntlm):
|
if not(user.pwd_ntlm):
|
||||||
# if we dont have NT hash, we create it
|
# if we dont have NT hash, we create it
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.template import Context, loader
|
from django.template import loader
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class Ticket(AclMixin, models.Model):
|
||||||
def publish_mail(self):
|
def publish_mail(self):
|
||||||
site_url = GeneralOption.objects.first().main_site_url
|
site_url = GeneralOption.objects.first().main_site_url
|
||||||
to_addr = Preferences.objects.first().publish_address
|
to_addr = Preferences.objects.first().publish_address
|
||||||
context = Context({'ticket':self,'site_url':site_url})
|
context = {'ticket':self,'site_url':site_url}
|
||||||
|
|
||||||
lang = Preferences.objects.first().mail_language
|
lang = Preferences.objects.first().mail_language
|
||||||
if(lang == 0):
|
if(lang == 0):
|
||||||
|
|
|
@ -16,12 +16,12 @@ class Migration(migrations.Migration):
|
||||||
machinetype = apps.get_model("machines", "MachineType")
|
machinetype = apps.get_model("machines", "MachineType")
|
||||||
borne = apps.get_model("topologie", "Borne")
|
borne = apps.get_model("topologie", "Borne")
|
||||||
interface = apps.get_model("machines", "Interface")
|
interface = apps.get_model("machines", "Interface")
|
||||||
bornes_list = machinetype.objects.using(db_alias).filter(type__icontains='borne')
|
bornes_list = machinetype.objects.using(db_alias).filter(ip_type__name__icontains='borne')
|
||||||
if bornes_list:
|
if bornes_list:
|
||||||
for inter in interface.objects.using(db_alias).filter(type=bornes_list.first()):
|
for inter in interface.objects.using(db_alias).filter(machine_type=bornes_list.first()):
|
||||||
borne_object = borne()
|
borne_object = borne()
|
||||||
borne_object.interface_ptr_id = inter.pk
|
borne_object.interface_ptr_id = inter.pk
|
||||||
borne_object.__dict__.update(inter.__dict__)
|
borne_object.__dict__.update(inter.__dict__)
|
||||||
borne_object.save()
|
borne_object.save()
|
||||||
|
|
||||||
def untransfer_bornes(apps, schema_editor):
|
def untransfer_bornes(apps, schema_editor):
|
||||||
|
|
|
@ -57,7 +57,7 @@ from django.forms import ValidationError
|
||||||
from django.db.models.signals import post_save, post_delete, m2m_changed
|
from django.db.models.signals import post_save, post_delete, m2m_changed
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.template import Context, loader
|
from django.template import loader
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
|
@ -78,7 +78,6 @@ import ldapdb.models
|
||||||
import ldapdb.models.fields
|
import ldapdb.models.fields
|
||||||
|
|
||||||
from re2o.settings import LDAP, GID_RANGES, UID_RANGES
|
from re2o.settings import LDAP, GID_RANGES, UID_RANGES
|
||||||
from re2o.login import hashNT
|
|
||||||
from re2o.field_permissions import FieldPermissionModelMixin
|
from re2o.field_permissions import FieldPermissionModelMixin
|
||||||
from re2o.mixins import AclMixin, RevMixin
|
from re2o.mixins import AclMixin, RevMixin
|
||||||
from re2o.base import smtp_check
|
from re2o.base import smtp_check
|
||||||
|
@ -426,6 +425,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
def is_adherent(self):
|
def is_adherent(self):
|
||||||
""" Renvoie True si l'user est adhérent : si
|
""" Renvoie True si l'user est adhérent : si
|
||||||
self.end_adhesion()>now"""
|
self.end_adhesion()>now"""
|
||||||
|
return True
|
||||||
end = self.end_adhesion()
|
end = self.end_adhesion()
|
||||||
if not end:
|
if not end:
|
||||||
return False
|
return False
|
||||||
|
@ -437,6 +437,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
""" Renvoie True si l'user est adhérent : si
|
""" Renvoie True si l'user est adhérent : si
|
||||||
self.end_adhesion()>now et end_connexion>now"""
|
self.end_adhesion()>now et end_connexion>now"""
|
||||||
|
return True
|
||||||
end = self.end_connexion()
|
end = self.end_connexion()
|
||||||
if not end:
|
if not end:
|
||||||
return False
|
return False
|
||||||
|
@ -712,14 +713,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
template = loader.get_template('users/email_welcome')
|
template = loader.get_template('users/email_welcome')
|
||||||
mailmessageoptions, _created = MailMessageOption\
|
mailmessageoptions, _created = MailMessageOption\
|
||||||
.objects.get_or_create()
|
.objects.get_or_create()
|
||||||
context = Context({
|
context = {
|
||||||
'nom': self.get_full_name(),
|
'nom': self.get_full_name(),
|
||||||
'asso_name': AssoOption.get_cached_value('name'),
|
'asso_name': AssoOption.get_cached_value('name'),
|
||||||
'asso_email': AssoOption.get_cached_value('contact'),
|
'asso_email': AssoOption.get_cached_value('contact'),
|
||||||
'welcome_mail_fr': mailmessageoptions.welcome_mail_fr,
|
'welcome_mail_fr': mailmessageoptions.welcome_mail_fr,
|
||||||
'welcome_mail_en': mailmessageoptions.welcome_mail_en,
|
'welcome_mail_en': mailmessageoptions.welcome_mail_en,
|
||||||
'pseudo': self.pseudo,
|
'pseudo': self.pseudo,
|
||||||
})
|
}
|
||||||
send_mail(
|
send_mail(
|
||||||
'Bienvenue au %(name)s / Welcome to %(name)s' % {
|
'Bienvenue au %(name)s / Welcome to %(name)s' % {
|
||||||
'name': AssoOption.get_cached_value('name')
|
'name': AssoOption.get_cached_value('name')
|
||||||
|
@ -775,7 +776,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
machine_parent.user = self
|
machine_parent.user = self
|
||||||
interface_cible = Interface()
|
interface_cible = Interface()
|
||||||
interface_cible.mac_address = mac_address
|
interface_cible.mac_address = mac_address
|
||||||
interface_cible.type = machine_type_cible
|
interface_cible.machine_type = machine_type_cible
|
||||||
interface_cible.clean()
|
interface_cible.clean()
|
||||||
machine_parent.clean()
|
machine_parent.clean()
|
||||||
domain = Domain()
|
domain = Domain()
|
||||||
|
@ -797,14 +798,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
"""Notification mail lorsque une machine est automatiquement
|
"""Notification mail lorsque une machine est automatiquement
|
||||||
ajoutée par le radius"""
|
ajoutée par le radius"""
|
||||||
template = loader.get_template('users/email_auto_newmachine')
|
template = loader.get_template('users/email_auto_newmachine')
|
||||||
context = Context({
|
context = {
|
||||||
'nom': self.get_full_name(),
|
'nom': self.get_full_name(),
|
||||||
'mac_address': interface.mac_address,
|
'mac_address': interface.mac_address,
|
||||||
'asso_name': AssoOption.get_cached_value('name'),
|
'asso_name': AssoOption.get_cached_value('name'),
|
||||||
'interface_name': interface.domain,
|
'interface_name': interface.domain,
|
||||||
'asso_email': AssoOption.get_cached_value('contact'),
|
'asso_email': AssoOption.get_cached_value('contact'),
|
||||||
'pseudo': self.pseudo,
|
'pseudo': self.pseudo,
|
||||||
})
|
}
|
||||||
send_mail(
|
send_mail(
|
||||||
"Ajout automatique d'une machine / New machine autoregistered",
|
"Ajout automatique d'une machine / New machine autoregistered",
|
||||||
'',
|
'',
|
||||||
|
@ -817,6 +818,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
def set_password(self, password):
|
def set_password(self, password):
|
||||||
""" A utiliser de préférence, set le password en hash courrant et
|
""" A utiliser de préférence, set le password en hash courrant et
|
||||||
dans la version ntlm"""
|
dans la version ntlm"""
|
||||||
|
from re2o.login import hashNT
|
||||||
super().set_password(password)
|
super().set_password(password)
|
||||||
self.pwd_ntlm = hashNT(password)
|
self.pwd_ntlm = hashNT(password)
|
||||||
return
|
return
|
||||||
|
@ -1522,12 +1524,12 @@ class Ban(RevMixin, AclMixin, models.Model):
|
||||||
def notif_ban(self):
|
def notif_ban(self):
|
||||||
""" Prend en argument un objet ban, envoie un mail de notification """
|
""" Prend en argument un objet ban, envoie un mail de notification """
|
||||||
template = loader.get_template('users/email_ban_notif')
|
template = loader.get_template('users/email_ban_notif')
|
||||||
context = Context({
|
context = {
|
||||||
'name': self.user.get_full_name(),
|
'name': self.user.get_full_name(),
|
||||||
'raison': self.raison,
|
'raison': self.raison,
|
||||||
'date_end': self.date_end,
|
'date_end': self.date_end,
|
||||||
'asso_name': AssoOption.get_cached_value('name'),
|
'asso_name': AssoOption.get_cached_value('name'),
|
||||||
})
|
}
|
||||||
send_mail(
|
send_mail(
|
||||||
'Déconnexion disciplinaire / Disciplinary disconnection',
|
'Déconnexion disciplinaire / Disciplinary disconnection',
|
||||||
template.render(context),
|
template.render(context),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from django.forms.widgets import Input
|
from django.forms.widgets import Input
|
||||||
from django.forms.utils import flatatt
|
from django.forms.utils import flatatt
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.template import Context, Template
|
from django.template import Template
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _, get_language_bidi
|
from django.utils.translation import ugettext_lazy as _, get_language_bidi
|
||||||
|
@ -28,7 +28,7 @@ class DateTimePicker(Input):
|
||||||
def render(self, name, value, attrs=None):
|
def render(self, name, value, attrs=None):
|
||||||
super().render(name, value, attrs)
|
super().render(name, value, attrs)
|
||||||
flat_attrs = flatatt(attrs)
|
flat_attrs = flatatt(attrs)
|
||||||
context = Context({
|
context = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'attrs': flat_attrs,
|
'attrs': flat_attrs,
|
||||||
'id': attrs['id'],
|
'id': attrs['id'],
|
||||||
|
@ -44,7 +44,7 @@ class DateTimePicker(Input):
|
||||||
'nextText': mark_safe('"' + str(_('Next')) + '"'),
|
'nextText': mark_safe('"' + str(_('Next')) + '"'),
|
||||||
'prevText': mark_safe('"' + str(_('Previous')) + '"'),
|
'prevText': mark_safe('"' + str(_('Previous')) + '"'),
|
||||||
'weekHeader': mark_safe('"' + str(_('Wk')) + '"' ),
|
'weekHeader': mark_safe('"' + str(_('Wk')) + '"' ),
|
||||||
})
|
}
|
||||||
template = get_template('users/datetimepicker.html')
|
template = get_template('users/datetimepicker.html')
|
||||||
return template.render(context)
|
return template.render(context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue