Esempio n. 1
0
 def save(self, **kwargs):
     use_https = kwargs.pop('use_https', False)
     token_generator = kwargs.pop('token_generator', default_token_generator)
     request = kwargs.pop('request', None)
     from_email = kwargs.pop('from_email', None)
     
     for user in self.users_cache:
         site_name = current_site.name
         domain = current_site.domain
         
         subject = _("Password reset on %s") % site_name
         context = {
             'email': user.email,
             'domain': domain,
             'site_name': site_name,
             'uid': int_to_base36(user.id),
             'user': user,
             'token': token_generator.make_token(user),
             'protocol': use_https and 'https' or 'http',
         }
         
         mail = Mailer(subject, 'mail.password_instructions.txt',
                                'mail.password_instructions.html', 
                                **context)
         mail.send(user.email, from_email)
Esempio n. 2
0
    def save(self, *args, **kwargs):
        """
        Almacena en la base de datos el nuevo usuario y envia un mail de 
        bienvenida.
        """
        
        # Crea el usuario
        user = super(RegisterForm, self).save(*args, **kwargs)
        
        # Envia el mail de bienvenida.
        context = {
            'user': user,
        }
        subject = _(u'%(firstname)s Bienvenido a %(sitename)s') % ({
            'firstname': user.first_name, 
            'sitename': current_site.name
        })

        mail = Mailer(subject, 'mail.welcome.txt',
                               'mail.welcome.html', 
                               **context)
        mail.send(user.email)

        return user