Beispiel #1
0
 def save_model(self, request, obj, form, change):
     """
     If the ``ACCOUNTS_APPROVAL_REQUIRED`` setting is ``True``,
     send a notification email to the user being saved if their
     ``active`` status has changed to ``True``.
     """
     if change and settings.ACCOUNTS_APPROVAL_REQUIRED:
         if obj.is_active and not User.objects.get(id=obj.id).is_active:
             send_approved_mail(request, obj)
     super(UserProfileAdmin, self).save_model(request, obj, form, change)
Beispiel #2
0
 def save_model(self, request, obj, form, change):
     """
     If the ``ACCOUNTS_APPROVAL_REQUIRED`` setting is ``True``,
     send a notification email to the user being saved if their
     ``active`` status has changed to ``True``.
     """
     if change and settings.ACCOUNTS_APPROVAL_REQUIRED:
         if obj.is_active and not User.objects.get(id=obj.id).is_active:
             send_approved_mail(request, obj)
     super(UserProfileAdmin, self).save_model(request, obj, form, change)
Beispiel #3
0
 def save_model(self, request, obj, form, change):
     """
     If the ``ACCOUNTS_APPROVAL_REQUIRED`` setting is ``True``,
     send a notification email to the user being saved if their
     ``active`` status has changed to ``True``.
     If the ``ACCOUNTS_VERIFICATION_REQUIRED`` setting is ``True``,
     send a verification email instead.
     """
     must_send_verification_mail_after_save = False
     if change and settings.ACCOUNTS_APPROVAL_REQUIRED:
         if obj.is_active and not User.objects.get(id=obj.id).is_active:
             if settings.ACCOUNTS_VERIFICATION_REQUIRED:
                 # Accounts verification requires an inactive account
                 obj.is_active = False
                 # The token generated by send_verification_mail()
                 # must match the _saved_ User object,
                 # so postpone send_verification_mail() until later
                 must_send_verification_mail_after_save = True
             else:
                 send_approved_mail(request, obj)
     super(UserProfileAdmin, self).save_model(request, obj, form, change)
     if must_send_verification_mail_after_save:
         user = User.objects.get(id=obj.id)
         send_verification_mail(request, user, "signup_verify")
Beispiel #4
0
 def save_model(self, request, obj, form, change):
     """
     If the ``ACCOUNTS_APPROVAL_REQUIRED`` setting is ``True``,
     send a notification email to the user being saved if their
     ``active`` status has changed to ``True``.
     If the ``ACCOUNTS_VERIFICATION_REQUIRED`` setting is ``True``,
     send a verification email instead.
     """
     must_send_verification_mail_after_save = False
     if change and settings.ACCOUNTS_APPROVAL_REQUIRED:
         if obj.is_active and not User.objects.get(id=obj.id).is_active:
             if settings.ACCOUNTS_VERIFICATION_REQUIRED:
                 # Accounts verification requires an inactive account
                 obj.is_active = False
                 # The token generated by send_verification_mail()
                 # must match the _saved_ User object,
                 # so postpone send_verification_mail() until later
                 must_send_verification_mail_after_save = True
             else:
                 send_approved_mail(request, obj)
     super(UserProfileAdmin, self).save_model(request, obj, form, change)
     if must_send_verification_mail_after_save:
         user = User.objects.get(id=obj.id)
         send_verification_mail(request, user, "signup_verify")