Example #1
0
    def save(self):
        for user in User.objects.filter(email__iexact=self.cleaned_data["email"]):
            temp_key = sha_constructor("%s%s%s" % (settings.SECRET_KEY, user.email, settings.SECRET_KEY)).hexdigest()

            # save it to the password reset model
            password_reset = PasswordReset(user=user, temp_key=temp_key)
            password_reset.save()

            current_site = Site.objects.get_current()
            domain = unicode(current_site.domain)

            # send the password reset email
            subject = _("Password reset email sent")
            message = render_to_string(
                "account/password_reset_key_message.txt", {"user": user, "temp_key": temp_key, "domain": domain}
            )
            send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email], priority="high")
        return self.cleaned_data["email"]
Example #2
0
    def send_approval_email(self, site):
        ctx_dict = {
            'profile': self
        }

        subject = render_to_string('registration/approval_email_subject.txt',
                                   ctx_dict)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())

        message = render_to_string('registration/approval_email.txt',
                                   ctx_dict)
        from_addr = settings.DEFAULT_FROM_EMAIL

        to = getattr(settings,
            "USER_APPROVAL_EMAIL_LIST",
            [settings.CONTACT_EMAIL])

        send_mail(subject, message, from_addr, to)
Example #3
0
    def send_activation_email(self, site):
        """
        Overrides the base method to add the profile itself to the
        activation templates

        """
        ctx_dict = {'activation_key': self.activation_key,
                    'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
                    'site': site,
                    'profile': self,
                    'SITE_NAME': settings.SITE_NAME,
                    'CONTACT_EMAIL': settings.CONTACT_EMAIL}

        subject = render_to_string('registration/activation_email_subject.txt',
                                   ctx_dict)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())

        message = render_to_string('registration/activation_email.txt',
                                   ctx_dict)
        from_addr = settings.DEFAULT_FROM_EMAIL

        send_mail(subject, message, from_addr, [self.user.email])