mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Allow admin to modify email state
This commit is contained in:
parent
93dcc79cad
commit
c2f180896f
4 changed files with 18 additions and 6 deletions
|
@ -650,11 +650,11 @@ class EditServiceUserForm(ServiceUserForm):
|
|||
|
||||
|
||||
class StateForm(FormRevMixin, ModelForm):
|
||||
""" Changement de l'état d'un user"""
|
||||
"""Change state of an user, and if its main email is verified or not"""
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["state"]
|
||||
fields = ["state" ,"email_state"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop("prefix", self.Meta.model.__name__)
|
||||
|
|
|
@ -1360,8 +1360,8 @@ msgid "Sent a new confirmation email."
|
|||
msgstr "Un nouveau mail de confirmation a été envoyé."
|
||||
|
||||
#: users/views.py:225
|
||||
msgid "The state was edited."
|
||||
msgstr "L'état a été modifié."
|
||||
msgid "The states were edited."
|
||||
msgstr "Les états ont été modifié."
|
||||
|
||||
#: users/views.py:242
|
||||
msgid "The groups were edited."
|
||||
|
|
|
@ -828,6 +828,16 @@ class User(
|
|||
self.confirm_email_address_mail(request)
|
||||
return True
|
||||
|
||||
def trigger_email_changed_state(self, request):
|
||||
"""Trigger an email, and changed values after email_state been manually updated"""
|
||||
if self.email_state == self.EMAIL_STATE_VERIFIED:
|
||||
return False
|
||||
|
||||
self.email_change_date = timezone.now()
|
||||
|
||||
self.confirm_email_address_mail(request)
|
||||
return True
|
||||
|
||||
def confirm_email_before_date(self):
|
||||
if self.email_state == self.EMAIL_STATE_VERIFIED:
|
||||
return None
|
||||
|
|
|
@ -243,8 +243,10 @@ def state(request, user, userid):
|
|||
state_form = StateForm(request.POST or None, instance=user)
|
||||
if state_form.is_valid():
|
||||
if state_form.changed_data:
|
||||
state_form.save()
|
||||
messages.success(request, _("The state was edited."))
|
||||
user_instance = state_form.save()
|
||||
messages.success(request, _("The states were edited."))
|
||||
if user_instance.trigger_email_changed_state(request):
|
||||
messages.success(request, _("An email to confirm the address was sent."))
|
||||
return redirect(reverse("users:profil", kwargs={"userid": str(userid)}))
|
||||
return form(
|
||||
{"userform": state_form, "action_name": _("Edit")},
|
||||
|
|
Loading…
Reference in a new issue