8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-09 03:16:25 +00:00

Move user email_change_date update on manual state change to seperate method

This commit is contained in:
Jean-Romain Garnier 2020-04-17 13:01:10 +02:00 committed by Gabriel Detraz
parent e0de606221
commit 80124695ad
2 changed files with 12 additions and 2 deletions

View file

@ -675,6 +675,7 @@ class StateForm(FormRevMixin, ModelForm):
if self.cleaned_data["state"]: if self.cleaned_data["state"]:
user.state = self.cleaned_data.get("state") user.state = self.cleaned_data.get("state")
user.state_sync() user.state_sync()
user.email_change_date_sync()
user.save() user.save()

View file

@ -638,12 +638,11 @@ class User(
self.ldap_sync() self.ldap_sync()
def state_sync(self): def state_sync(self):
"""Handle archiving/unarchiving, and manually confirming a user's email address""" """Archive, or unarchive, if the user was not active/or archived before"""
if ( if (
self.__original_state != self.STATE_ACTIVE self.__original_state != self.STATE_ACTIVE
and self.state == self.STATE_ACTIVE and self.state == self.STATE_ACTIVE
): ):
self.email_change_date = None
self.unarchive() self.unarchive()
elif ( elif (
self.__original_state != self.STATE_ARCHIVE self.__original_state != self.STATE_ARCHIVE
@ -655,11 +654,21 @@ class User(
and self.state == self.STATE_FULL_ARCHIVE and self.state == self.STATE_FULL_ARCHIVE
): ):
self.full_archive() self.full_archive()
def email_change_date_sync(self):
"""Update user's email_change_date based on state update"""
if (
self.__original_state != self.STATE_ACTIVE
and self.state == self.STATE_ACTIVE
):
self.email_change_date = None
self.save()
elif ( elif (
self.__original_state != self.STATE_EMAIL_NOT_YET_CONFIRMED self.__original_state != self.STATE_EMAIL_NOT_YET_CONFIRMED
and self.state == self.STATE_EMAIL_NOT_YET_CONFIRMED and self.state == self.STATE_EMAIL_NOT_YET_CONFIRMED
): ):
self.email_change_date = timezone.now() self.email_change_date = timezone.now()
self.save()
def ldap_sync( def ldap_sync(
self, base=True, access_refresh=True, mac_refresh=True, group_refresh=False self, base=True, access_refresh=True, mac_refresh=True, group_refresh=False