8
0
Fork 0
mirror of https://gitlab.federez.net/re2o/re2o synced 2024-07-02 04:04:06 +00:00

Merge branch 'buster_ready' into 'dev'

Buster ready

See merge request federez/re2o!430
This commit is contained in:
chirac 2019-09-05 21:47:40 +02:00
commit 41cbd572c0
9 changed files with 37 additions and 29 deletions

View file

@ -5,6 +5,7 @@ texlive-fonts-recommended
python3-djangorestframework
python3-django-reversion
python3-pip
python3-pil
libsasl2-dev libldap2-dev
libssl-dev
python3-crypto

View file

@ -33,7 +33,6 @@ from datetime import datetime
from django.db import models
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse
from django.conf import settings
from django.utils.text import slugify
@ -105,7 +104,7 @@ def create_pdf(template, ctx={}):
Returns:
The content of the temporary PDF file generated.
"""
context = Context(ctx)
context = ctx
template = get_template(template)
rendered_tpl = template.render(context).encode('utf-8')

View file

@ -103,7 +103,7 @@ install_database() {
if [ "$engine_type" == 1 ]; then
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"
mysql_command="CREATE DATABASE $db_name collate='utf8_general_ci';
@ -113,7 +113,7 @@ install_database() {
if [ "$local_setup" == 1 ]; then
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"
echo "Setting up local MySQL server: Done"
else
@ -763,8 +763,9 @@ main_function() {
echo " * {help} ---------- Display this quick usage documentation"
echo " * {setup} --------- Launch the full interactive guide to setup entirely"
echo " re2o from scratch"
echo " * {update} -------- Collect frontend statics, install the missing APT and copy LaTeX templates files"
echo " and pip packages and apply the migrations to the DB"
echo " * {update} -------- Collect frontend statics, install the missing APT"
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 " * {copy-template-files} - Copy LaTeX templates files to media/templates"
echo " * {update-packages} Install the missing APT and pip packages"
@ -840,7 +841,7 @@ main_function() {
db_username="re2o"
fi
install_database "$db_engine_type" 1 "$db_name" "$db_username" "$db_password"
update-django
update_django
else
echo "Invalid arguments !"
echo "Usage: install_re2o setup-db <db_password> [<db_engine_type>] [<db_name>] [<db_username>]"

View file

@ -158,10 +158,15 @@ ModelC)
messages.error(
request, msg or _("You don't have the right to access"
" this menu."))
return redirect(reverse(
'users:profil',
kwargs={'userid': str(request.user.id)}
))
if request.user.id is not None:
return redirect(reverse(
'users:profil',
kwargs={'userid': str(request.user.id)}
))
else:
return redirect(reverse(
'index',
))
return view(request, *chain(instances, args), **kwargs)
return wrapper
return decorator

View file

@ -232,7 +232,7 @@ class SSHAPasswordHasher(hashers.BasePasswordHasher):
class RecryptBackend(ModelBackend):
def authenticate(self, username=None, password=None):
# 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 not(user.pwd_ntlm):
# if we dont have NT hash, we create it

View file

@ -1,7 +1,7 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
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.dispatch import receiver
@ -52,7 +52,7 @@ class Ticket(AclMixin, models.Model):
def publish_mail(self):
site_url = GeneralOption.objects.first().main_site_url
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
if(lang == 0):

View file

@ -16,12 +16,12 @@ class Migration(migrations.Migration):
machinetype = apps.get_model("machines", "MachineType")
borne = apps.get_model("topologie", "Borne")
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:
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.interface_ptr_id = inter.pk
borne_object.__dict__.update(inter.__dict__)
borne_object.__dict__.update(inter.__dict__)
borne_object.save()
def untransfer_bornes(apps, schema_editor):

View file

@ -57,7 +57,7 @@ from django.forms import ValidationError
from django.db.models.signals import post_save, post_delete, m2m_changed
from django.dispatch import receiver
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.urlresolvers import reverse
from django.db import transaction
@ -78,7 +78,6 @@ import ldapdb.models
import ldapdb.models.fields
from re2o.settings import LDAP, GID_RANGES, UID_RANGES
from re2o.login import hashNT
from re2o.field_permissions import FieldPermissionModelMixin
from re2o.mixins import AclMixin, RevMixin
from re2o.base import smtp_check
@ -426,6 +425,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
def is_adherent(self):
""" Renvoie True si l'user est adhérent : si
self.end_adhesion()>now"""
return True
end = self.end_adhesion()
if not end:
return False
@ -437,6 +437,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
def is_connected(self):
""" Renvoie True si l'user est adhérent : si
self.end_adhesion()>now et end_connexion>now"""
return True
end = self.end_connexion()
if not end:
return False
@ -712,14 +713,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
template = loader.get_template('users/email_welcome')
mailmessageoptions, _created = MailMessageOption\
.objects.get_or_create()
context = Context({
context = {
'nom': self.get_full_name(),
'asso_name': AssoOption.get_cached_value('name'),
'asso_email': AssoOption.get_cached_value('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': AssoOption.get_cached_value('name')
@ -775,7 +776,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
machine_parent.user = self
interface_cible = Interface()
interface_cible.mac_address = mac_address
interface_cible.type = machine_type_cible
interface_cible.machine_type = machine_type_cible
interface_cible.clean()
machine_parent.clean()
domain = Domain()
@ -797,14 +798,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
"""Notification mail lorsque une machine est automatiquement
ajoutée par le radius"""
template = loader.get_template('users/email_auto_newmachine')
context = Context({
context = {
'nom': self.get_full_name(),
'mac_address': interface.mac_address,
'asso_name': AssoOption.get_cached_value('name'),
'interface_name': interface.domain,
'asso_email': AssoOption.get_cached_value('contact'),
'pseudo': self.pseudo,
})
}
send_mail(
"Ajout automatique d'une machine / New machine autoregistered",
'',
@ -817,6 +818,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
def set_password(self, password):
""" A utiliser de préférence, set le password en hash courrant et
dans la version ntlm"""
from re2o.login import hashNT
super().set_password(password)
self.pwd_ntlm = hashNT(password)
return
@ -1522,12 +1524,12 @@ class Ban(RevMixin, AclMixin, models.Model):
def notif_ban(self):
""" Prend en argument un objet ban, envoie un mail de notification """
template = loader.get_template('users/email_ban_notif')
context = Context({
context = {
'name': self.user.get_full_name(),
'raison': self.raison,
'date_end': self.date_end,
'asso_name': AssoOption.get_cached_value('name'),
})
}
send_mail(
'Déconnexion disciplinaire / Disciplinary disconnection',
template.render(context),

View file

@ -1,7 +1,7 @@
from django.forms.widgets import Input
from django.forms.utils import flatatt
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.conf import settings
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):
super().render(name, value, attrs)
flat_attrs = flatatt(attrs)
context = Context({
context = {
'name': name,
'attrs': flat_attrs,
'id': attrs['id'],
@ -44,7 +44,7 @@ class DateTimePicker(Input):
'nextText': mark_safe('"' + str(_('Next')) + '"'),
'prevText': mark_safe('"' + str(_('Previous')) + '"'),
'weekHeader': mark_safe('"' + str(_('Wk')) + '"' ),
})
}
template = get_template('users/datetimepicker.html')
return template.render(context)