change to user serializer
This commit is contained in:
@@ -53,7 +53,7 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||||
email_verified = models.BooleanField('Email verificado', default=False, null=True)
|
||||
company = models.ForeignKey(Company, null=True, on_delete=models.DO_NOTHING, related_name='custom_user')
|
||||
|
||||
is_active = models.BooleanField('Activo', default=False)
|
||||
is_active = models.BooleanField('Activo', default=True)
|
||||
is_staff = models.BooleanField('Empleado',default=False )
|
||||
|
||||
modified = models.DateTimeField(auto_now=True, null=True, blank=True)
|
||||
|
||||
@@ -14,7 +14,7 @@ class CustomUserReadSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = models.CustomUser
|
||||
fields = ('email', 'full_name', 'role', 'is_active', 'provider')
|
||||
fields = ('id', 'email', 'full_name', 'role', 'is_active', 'provider', 'notify')
|
||||
|
||||
|
||||
class CustomUserWriteSerializer(serializers.ModelSerializer):
|
||||
|
||||
@@ -38,7 +38,7 @@ class CustomUserViewSetTest(APITestCase):
|
||||
self.user = self.factory(email=self.reg_email, password=self.password, is_active=True)
|
||||
|
||||
# anon user
|
||||
def test_anon_user_can_create_inactive_instance(self):
|
||||
def test_anon_user_can_create_active_instance(self):
|
||||
"""Not logged-in user can create new instance of User but it's inactive
|
||||
TODO: should create inactive user
|
||||
"""
|
||||
@@ -55,7 +55,7 @@ class CustomUserViewSetTest(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
# assert instance is inactive
|
||||
info = json.loads(response.content)
|
||||
self.assertFalse(info['is_active'])
|
||||
self.assertTrue(info['is_active'])
|
||||
|
||||
def test_anon_user_cannot_modify_existing_instance(self):
|
||||
"""Not logged-in user cannot modify existing instance
|
||||
@@ -196,7 +196,8 @@ class CustomUserViewSetTest(APITestCase):
|
||||
# Define request data
|
||||
data = {
|
||||
'email': 'test_alt@email.com',
|
||||
'full_name': 'TEST NAME ALT'
|
||||
'full_name': 'TEST NAME ALT',
|
||||
'notify': True,
|
||||
}
|
||||
|
||||
# Authenticate user
|
||||
@@ -346,6 +347,7 @@ class UpdateUserViewTest(APITestCase):
|
||||
"email": "new_email@mail.com",
|
||||
"full_name": "New Full Name",
|
||||
'provider': 'PROVIDER',
|
||||
'notify': True,
|
||||
}
|
||||
|
||||
# Authenticate
|
||||
|
||||
Reference in New Issue
Block a user