mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Users - déplacement de OptionalUser et migration
This commit is contained in:
parent
7f07b1ed48
commit
970307a6cf
8 changed files with 118 additions and 7 deletions
|
@ -29,7 +29,6 @@ from django.contrib import admin
|
||||||
from reversion.admin import VersionAdmin
|
from reversion.admin import VersionAdmin
|
||||||
|
|
||||||
from .models import (
|
from .models import (
|
||||||
OptionalUser,
|
|
||||||
OptionalMachine,
|
OptionalMachine,
|
||||||
OptionalTopologie,
|
OptionalTopologie,
|
||||||
GeneralOption,
|
GeneralOption,
|
||||||
|
@ -44,6 +43,7 @@ from .models import (
|
||||||
DocumentTemplate
|
DocumentTemplate
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from users.preferences.models import PreferencesUser as OptionalUser
|
||||||
|
|
||||||
class OptionalUserAdmin(VersionAdmin):
|
class OptionalUserAdmin(VersionAdmin):
|
||||||
"""Class admin options user"""
|
"""Class admin options user"""
|
||||||
|
|
|
@ -30,7 +30,6 @@ from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from re2o.mixins import FormRevMixin
|
from re2o.mixins import FormRevMixin
|
||||||
from .models import (
|
from .models import (
|
||||||
OptionalUser,
|
|
||||||
OptionalMachine,
|
OptionalMachine,
|
||||||
OptionalTopologie,
|
OptionalTopologie,
|
||||||
GeneralOption,
|
GeneralOption,
|
||||||
|
@ -46,6 +45,7 @@ from .models import (
|
||||||
CotisationsOption,
|
CotisationsOption,
|
||||||
DocumentTemplate
|
DocumentTemplate
|
||||||
)
|
)
|
||||||
|
from users.preferences.models import PreferencesUser as OptionalUser
|
||||||
from topologie.models import Switch
|
from topologie.models import Switch
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ from .forms import (
|
||||||
from .models import (
|
from .models import (
|
||||||
Service,
|
Service,
|
||||||
MailContact,
|
MailContact,
|
||||||
OptionalUser,
|
|
||||||
OptionalMachine,
|
OptionalMachine,
|
||||||
AssoOption,
|
AssoOption,
|
||||||
MailMessageOption,
|
MailMessageOption,
|
||||||
|
@ -71,6 +70,8 @@ from .models import (
|
||||||
CotisationsOption,
|
CotisationsOption,
|
||||||
DocumentTemplate
|
DocumentTemplate
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from users.preferences.models import PreferencesUser as OptionalUser
|
||||||
from . import models
|
from . import models
|
||||||
from . import forms
|
from . import forms
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ which indicated if a user can creates an account by himself
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django import template
|
from django import template
|
||||||
from preferences.models import OptionalUser
|
from users.preferences.models import PreferencesUser as OptionalUser
|
||||||
|
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
|
@ -44,7 +44,7 @@ from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from machines.models import Interface, Machine, Nas
|
from machines.models import Interface, Machine, Nas
|
||||||
from topologie.models import Port
|
from topologie.models import Port
|
||||||
from preferences.models import OptionalUser
|
from .preferences.models import PreferencesUser as OptionalUser
|
||||||
from re2o.utils import remove_user_room
|
from re2o.utils import remove_user_room
|
||||||
from re2o.base import get_input_formats_help_text
|
from re2o.base import get_input_formats_help_text
|
||||||
from re2o.mixins import FormRevMixin
|
from re2o.mixins import FormRevMixin
|
||||||
|
|
|
@ -85,7 +85,8 @@ from re2o.base import smtp_check
|
||||||
|
|
||||||
from cotisations.models import Cotisation, Facture, Paiement, Vente
|
from cotisations.models import Cotisation, Facture, Paiement, Vente
|
||||||
from machines.models import Domain, Interface, Machine, regen
|
from machines.models import Domain, Interface, Machine, regen
|
||||||
from preferences.models import GeneralOption, AssoOption, OptionalUser
|
from preferences.models import GeneralOption, AssoOption
|
||||||
|
from .preferences.models import PreferencesUser as OptionalUser
|
||||||
from preferences.models import OptionalMachine, MailMessageOption
|
from preferences.models import OptionalMachine, MailMessageOption
|
||||||
|
|
||||||
|
|
||||||
|
|
108
users/preferences/models.py
Normal file
108
users/preferences/models.py
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# quelques clics.
|
||||||
|
#
|
||||||
|
# Copyright © 2017 Gabriel Détraz
|
||||||
|
# Copyright © 2017 Goulven Kermarec
|
||||||
|
# Copyright © 2017 Augustin Lemesle
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along
|
||||||
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
from django.forms import ValidationError
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from re2o.mixins import AclMixin
|
||||||
|
|
||||||
|
from preferences.models import PreferencesModel
|
||||||
|
|
||||||
|
class PreferencesUser(AclMixin, PreferencesModel):
|
||||||
|
"""Options pour l'user : obligation ou nom du telephone,
|
||||||
|
activation ou non du solde, autorisation du negatif, fingerprint etc"""
|
||||||
|
|
||||||
|
is_tel_mandatory = models.BooleanField(default=True)
|
||||||
|
gpg_fingerprint = models.BooleanField(default=True)
|
||||||
|
all_can_create_club = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("Users can create a club.")
|
||||||
|
)
|
||||||
|
all_can_create_adherent = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("Users can create a member."),
|
||||||
|
)
|
||||||
|
|
||||||
|
shell_default = models.OneToOneField(
|
||||||
|
'users.ListShell',
|
||||||
|
on_delete=models.PROTECT,
|
||||||
|
blank=True,
|
||||||
|
null=True
|
||||||
|
)
|
||||||
|
self_change_shell = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("Users can edit their shell.")
|
||||||
|
)
|
||||||
|
self_change_room = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("Users can edit their room.")
|
||||||
|
)
|
||||||
|
local_email_accounts_enabled = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("Enable local email accounts for users.")
|
||||||
|
)
|
||||||
|
local_email_domain = models.CharField(
|
||||||
|
max_length=32,
|
||||||
|
default="@example.org",
|
||||||
|
help_text=_("Domain to use for local email accounts")
|
||||||
|
)
|
||||||
|
max_email_address = models.IntegerField(
|
||||||
|
default=15,
|
||||||
|
help_text=_("Maximum number of local email addresses for a standard"
|
||||||
|
" user.")
|
||||||
|
)
|
||||||
|
delete_notyetactive = models.IntegerField(
|
||||||
|
default=15,
|
||||||
|
help_text=_("Not yet active users will be deleted after this number of"
|
||||||
|
" days.")
|
||||||
|
)
|
||||||
|
self_adhesion = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("A new user can create their account on Re2o.")
|
||||||
|
)
|
||||||
|
all_users_active = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=_("If True, all new created and connected users are active."
|
||||||
|
" If False, only when a valid registration has been paid.")
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
permissions = (
|
||||||
|
("view_optionaluser", _("Can view the user options")),
|
||||||
|
)
|
||||||
|
verbose_name = _("user options")
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
"""Clean model:
|
||||||
|
Check the mail_extension
|
||||||
|
"""
|
||||||
|
if self.local_email_domain[0] != "@":
|
||||||
|
raise ValidationError(_("Email domain must begin with @"))
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=PreferencesUser)
|
||||||
|
def preferencesUser_post_save(**kwargs):
|
||||||
|
"""Ecriture dans le cache"""
|
||||||
|
user_pref = kwargs['instance']
|
||||||
|
user_pref.set_in_cache()
|
|
@ -55,7 +55,8 @@ from reversion import revisions as reversion
|
||||||
from cotisations.models import Facture, Paiement
|
from cotisations.models import Facture, Paiement
|
||||||
from machines.models import Machine
|
from machines.models import Machine
|
||||||
|
|
||||||
from preferences.models import OptionalUser, GeneralOption, AssoOption
|
from preferences.models import GeneralOption, AssoOption
|
||||||
|
from .preferences.models import PreferencesUser as OptionalUser
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from re2o.settings_local import OPTIONNAL_APPS_RE2O
|
from re2o.settings_local import OPTIONNAL_APPS_RE2O
|
||||||
from re2o.views import form
|
from re2o.views import form
|
||||||
|
|
Loading…
Reference in a new issue