Example #1
0
 def test_accounts_list(self):
     """
     If no polls exist, an appropriate message should be displayed.
     """
     account = Account(email='*****@*****.**', password='******')
     account.first_name = 'user1'
     account.last_name = 'mail'
     account.is_active = True
     now = datetime.datetime.now()
     account.created_at = now
     account.updated_at = now
     account.save()
     response = self.client.get(reverse('account-list'))
     self.assertEqual(response.status_code, 200)
Example #2
0
 def save(self):
     account = Account(email=self.validated_data['email'],
                       username=self.validated_data['username'])
     password = self.validated_data['password']
     password2 = self.validated_data['password2']
     if password != password2:
         raise serializers.ValidationError({
             'password': '******',
             'key': 'password.mismatch'
         })
     account.set_password(password)
     account.is_active = False
     account.save()
     return account
Example #3
0
    def save(self):
        account = Account(
            username = self.validated_data['username'],
            email = self.validated_data['email'],

        )
        password = self.validated_data['password']
        password2 = self.validated_data['password2']

        if password != password2:
            raise serializers.ValidationError({
            'password': '******'t match!'
        })

        account.set_password(password)
        account.is_active = False
        account.save()
        return account