(self, domain_override=None,
             subject_template_name='registration/password_reset_subject.txt',
             email_template_name='registration/password_reset_email.html',
             # WARNING: Django 1.7 passes this in automatically. do not remove
             html_email_template_name=None,
             use_https=False, token_generator=default_token_generator,
             from_email=None, request=None, **kwargs)
Generates a one-use only link for resetting password and sends to the
        user.
Generates a one-use only link for resetting password and sends to the
        user.
Generates a one - use only link for resetting password and sends to the user .
def save(self, domain_override=None,
             subject_template_name='registration/password_reset_subject.txt',
             email_template_name='registration/password_reset_email.html',
             # WARNING: Django 1.7 passes this in automatically. do not remove
             html_email_template_name=None,
             use_https=False, token_generator=default_token_generator,
             from_email=None, request=None, **kwargs):
        """
        Generates a one-use only link for resetting password and sends to the
        user.
        """

        if settings.IS_SAAS_ENVIRONMENT:
            subject_template_name = 'registration/email/password_reset_subject_hq.txt'
            email_template_name = 'registration/email/password_reset_email_hq.html'

        email = self.cleaned_data["email"]

        # this is the line that we couldn't easily override in PasswordForm where
        # we specifically filter for the username, not the email, so that
        # mobile workers who have the same email set as a web worker don't
        # get a password reset email.
        active_users = get_active_users_by_email(email)

        # the code below is copied from default PasswordForm
        for user in active_users:
            # Make sure that no email is sent to a user that actually has
            # a password marked as unusable
            if not user.has_usable_password():
                continue
            if not domain_override:
                current_site = get_current_site(request)
                site_name = current_site.name
                domain = current_site.domain
            else:
                site_name = domain = domain_override

            couch_user = CouchUser.from_django_user(user)
            if not couch_user:
                continue

            user_email = couch_user.get_email()
            if not user_email:
                continue

            c = {
                'email': user_email,
                'domain': domain,
                'site_name': site_name,
                'uid': urlsafe_base64_encode(force_bytes(user.pk)),
                'user': user,
                'token': token_generator.make_token(user),
                'protocol': 'https' if use_https else 'http',
            }
            subject = render_to_string(subject_template_name, c)
            # Email subject *must not* contain newlines
            subject = ''.join(subject.splitlines())

            message_plaintext = render_to_string('registration/password_reset_email.html', c)
            message_html = render_to_string(email_template_name, c)

            send_html_email_async.delay(
                subject, user_email, message_html,
                text_content=message_plaintext,
                email_from=settings.DEFAULT_FROM_EMAIL
            )
def save ( self , domain_override = None , subject_template_name = 'registration/password_reset_subject.txt' , email_template_name = 'registration/password_reset_email.html' , # WARNING: Django 1.7 passes this in automatically. do not remove html_email_template_name = None , use_https = False , token_generator = default_token_generator , from_email = None , request = None , * * kwargs ) : if settings . IS_SAAS_ENVIRONMENT : subject_template_name = 'registration/email/password_reset_subject_hq.txt' email_template_name = 'registration/email/password_reset_email_hq.html' email = self . cleaned_data [ "email" ] # this is the line that we couldn't easily override in PasswordForm where # we specifically filter for the username, not the email, so that # mobile workers who have the same email set as a web worker don't # get a password reset email. active_users = get_active_users_by_email ( email ) # the code below is copied from default PasswordForm for user in active_users : # Make sure that no email is sent to a user that actually has # a password marked as unusable if not user . has_usable_password ( ) : continue if not domain_override : current_site = get_current_site ( request ) site_name = current_site . name domain = current_site . domain else : site_name = domain = domain_override couch_user = CouchUser . from_django_user ( user ) if not couch_user : continue user_email = couch_user . get_email ( ) if not user_email : continue c = { 'email' : user_email , 'domain' : domain , 'site_name' : site_name , 'uid' : urlsafe_base64_encode ( force_bytes ( user . pk ) ) , 'user' : user , 'token' : token_generator . make_token ( user ) , 'protocol' : 'https' if use_https else 'http' , } subject = render_to_string ( subject_template_name , c ) # Email subject *must not* contain newlines subject = '' . join ( subject . splitlines ( ) ) message_plaintext = render_to_string ( 'registration/password_reset_email.html' , c ) message_html = render_to_string ( email_template_name , c ) send_html_email_async . delay ( subject , user_email , message_html , text_content = message_plaintext , email_from = settings . DEFAULT_FROM_EMAIL )