Exemple #1
0
 def save(self, *args, **kwargs):
     create = True
     user = User()
     password = self.cleaned_data['new_password']
     user.name = self.cleaned_data['name']
     user.email = self.cleaned_data['email']
     user.username = self.cleaned_data['email']
     user.active = True
     user.is_superuser = False
     user.last_login = None
     user.date_joined = datetime.datetime.now()
     user.username = user.email
     user.set_password(password)
     if create:
         user.save()
         return user
     else:
         token = signing.dumps('{};{};{}'.format(user.name, user.email,
                                                 password))
         url = '{}/admin/create_user/{}/'.format(settings.SERVER_ADDRESS,
                                                 token)
         msg = '{}: {}'.format(
             _('Click on the link to activate your account'),
             url), settings.SYSTEM_EMAIL_ADDRESS
         user.email_user(_('Account Activation'), msg)
         return None
Exemple #2
0
 def save(self, *args, **kwargs):
     user = User()
     password = self.cleaned_data['new_password']
     user.name = self.cleaned_data['name']
     user.email = self.cleaned_data['email']
     user.username = self.cleaned_data['email']
     user.active = True
     user.is_superuser = False
     user.last_login = datetime.datetime.now()
     user.date_joined = datetime.datetime.now()
     user.username = user.email
     user.set_password(password)
     if True:
         user.save()
         return user
     else:
         token = encrypt('%s;%s;%s;%s' % (user.first_name, user.last_name, user.email, password))
         url = u'%s/admin/create_user/%s/' % (settings.SERVER_ADDRESS, token)
         user.email_user(u'Criação de Conta', u'Clique para confirmar a criação de sua conta: %s' % url,
                         settings.SYSTEM_EMAIL_ADDRESS)
         return None