mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Merge branch 'archive_accounts' into 'dev'
Archive accounts See merge request federez/re2o!346
This commit is contained in:
commit
c2f867ce31
3 changed files with 16 additions and 3 deletions
|
@ -530,6 +530,12 @@ class StateForm(FormRevMixin, ModelForm):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(StateForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(StateForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
def save(self, commit=True):
|
||||||
|
user = super(StateForm, self).save(commit=False)
|
||||||
|
if self.cleaned_data['state']:
|
||||||
|
user.state=self.cleaned_data.get('state')
|
||||||
|
user.state_sync()
|
||||||
|
user.save()
|
||||||
|
|
||||||
class GroupForm(FieldPermissionFormMixin, FormRevMixin, ModelForm):
|
class GroupForm(FieldPermissionFormMixin, FormRevMixin, ModelForm):
|
||||||
""" Gestion des groupes d'un user"""
|
""" Gestion des groupes d'un user"""
|
||||||
|
|
|
@ -543,9 +543,16 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
reversion.set_comment(_("IPv4 unassigning"))
|
reversion.set_comment(_("IPv4 unassigning"))
|
||||||
interface.save()
|
interface.save()
|
||||||
|
|
||||||
|
def disable_email(self):
|
||||||
|
"""Disable email account and redirection"""
|
||||||
|
self.email = ""
|
||||||
|
self.local_email_enabled = False
|
||||||
|
self.local_email_redirect = False
|
||||||
|
|
||||||
def archive(self):
|
def archive(self):
|
||||||
""" Filling the user; no more active"""
|
""" Filling the user; no more active"""
|
||||||
self.unassign_ips()
|
self.unassign_ips()
|
||||||
|
self.disable_email()
|
||||||
|
|
||||||
def unarchive(self):
|
def unarchive(self):
|
||||||
"""Unfilling the user"""
|
"""Unfilling the user"""
|
||||||
|
@ -1017,7 +1024,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
.filter(local_part=self.pseudo.lower()).exclude(user_id=self.id)
|
.filter(local_part=self.pseudo.lower()).exclude(user_id=self.id)
|
||||||
):
|
):
|
||||||
raise ValidationError("This pseudo is already in use.")
|
raise ValidationError("This pseudo is already in use.")
|
||||||
if not self.local_email_enabled and not self.email:
|
if not self.local_email_enabled and not self.email and not (self.state == self.STATE_ARCHIVE):
|
||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
{'email': (
|
{'email': (
|
||||||
_("There is neither a local email address nor an external"
|
_("There is neither a local email address nor an external"
|
||||||
|
@ -1885,4 +1892,3 @@ class EMailAddress(RevMixin, AclMixin, models.Model):
|
||||||
if "@" in self.local_part:
|
if "@" in self.local_part:
|
||||||
raise ValidationError(_("The local part must not contain @."))
|
raise ValidationError(_("The local part must not contain @."))
|
||||||
super(EMailAddress, self).clean(*args, **kwargs)
|
super(EMailAddress, self).clean(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -1034,7 +1034,8 @@ def reset_password(request):
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(
|
user = User.objects.get(
|
||||||
pseudo=userform.cleaned_data['pseudo'],
|
pseudo=userform.cleaned_data['pseudo'],
|
||||||
email=userform.cleaned_data['email']
|
email=userform.cleaned_data['email'],
|
||||||
|
state__in=[User.STATE_ACTIVE, User.STATE_NOT_YET_ACTIVE],
|
||||||
)
|
)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
messages.error(request, _("The user doesn't exist."))
|
messages.error(request, _("The user doesn't exist."))
|
||||||
|
|
Loading…
Reference in a new issue