Beispiel #1
0
    def form_valid(self, form):
        user = form.save(commit=False)
        logger.info(str(user) + " registered on the website.")
        user.is_active = False
        user.activation_link = id_generator(30)
        user.first_name = user.first_name.strip()
        user.middle_name = user.middle_name.strip()
        user.last_name = user.last_name.strip()
        user.email = user.email.strip()

        message = MailerMessage()
        context = {
            'site': RequestSite(self.request),
            'user': user,
            'username': get_username(user),
            'secure': self.request.is_secure(),
            "activation_link": user.activation_link
        }
        message.subject = "Registration"
        message.content = render_to_string("account/registration.html",
                                           context)
        message.from_address = "*****@*****.**"
        message.to_address = user.email
        message.save()
        user.save()
        messages.add_message(
            self.request, messages.INFO,
            'Registration successful. Please check your email to complete the process.'
        )
        return super(EestecerCreate, self).form_valid(form)
Beispiel #2
0
    def form_valid(self, form):
        user = form.save(commit=False)
        logger.info(str(user) + " registered on the website.")
        user.is_active = False
        user.activation_link = id_generator(30)
        user.first_name=user.first_name.strip()
        user.middle_name=user.middle_name.strip()
        user.last_name=user.last_name.strip()
        user.email = user.email.strip()

        message = MailerMessage()
        context = {
            'site': RequestSite(self.request),
            'user': user,
            'username': get_username(user),
            'secure': self.request.is_secure(),
            "activation_link": user.activation_link
        }
        message.subject = "Registration"
        message.content = render_to_string("account/registration.html", context)
        message.from_address = "*****@*****.**"
        message.to_address = user.email
        message.save()
        user.save()
        messages.add_message(
            self.request,
            messages.INFO,
            'Registration successful. Please check your email to complete the process.')
        return super(EestecerCreate, self).form_valid(form)
Beispiel #3
0
 def send_notification(self, user, password):
     context = {
         'user': user,
         'site': self.get_site(),
         'pass': password,
         'username': get_username(user),
         'secure': self.request.is_secure(),
     }
     body = loader.render_to_string(self.email_template_name,
                                    context).strip()
     subject = loader.render_to_string(self.email_subject_template_name,
                                       context).strip()
     send_mail(subject, body, FROM_EMAIL, [user.email])
Beispiel #4
0
 def send_notification(self):
     context = {
         'site': self.get_site(),
         'user': self.user,
         'username': get_username(self.user),
         'token': signing.dumps(self.user.pk, salt=self.salt),
         'secure': self.request.is_secure(),
     }
     body = loader.render_to_string(self.email_template_name,
                                             context).strip()
     subject = loader.render_to_string(self.email_subject_template_name,
                                             context).strip()
     send_mail(subject, body, settings.DEFAULT_FROM_EMAIL,
                                             [self.user.email],
                                             html_message=body)
Beispiel #5
0
    def send_notification(self):
        context = {
            'site': RequestSite(self.request),
            'user': self.user,
            'username': get_username(self.user),
            'token': signing.dumps(self.user.pk, salt=self.salt),
            'secure': self.request.is_secure(),
        }
        subject = loader.render_to_string(
            self.email_subject_template_name, context
        ).strip()

        mail.send_mail_from_template_with_noreply(
            self.email_template_name, context,
            subject=subject, to=[self.user.email]
        )