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)
|
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')
|
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 )
|
is_staff = models.BooleanField('Empleado',default=False )
|
||||||
|
|
||||||
modified = models.DateTimeField(auto_now=True, null=True, blank=True)
|
modified = models.DateTimeField(auto_now=True, null=True, blank=True)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class CustomUserReadSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.CustomUser
|
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):
|
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)
|
self.user = self.factory(email=self.reg_email, password=self.password, is_active=True)
|
||||||
|
|
||||||
# anon user
|
# 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
|
"""Not logged-in user can create new instance of User but it's inactive
|
||||||
TODO: should create inactive user
|
TODO: should create inactive user
|
||||||
"""
|
"""
|
||||||
@@ -55,7 +55,7 @@ class CustomUserViewSetTest(APITestCase):
|
|||||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
# assert instance is inactive
|
# assert instance is inactive
|
||||||
info = json.loads(response.content)
|
info = json.loads(response.content)
|
||||||
self.assertFalse(info['is_active'])
|
self.assertTrue(info['is_active'])
|
||||||
|
|
||||||
def test_anon_user_cannot_modify_existing_instance(self):
|
def test_anon_user_cannot_modify_existing_instance(self):
|
||||||
"""Not logged-in user cannot modify existing instance
|
"""Not logged-in user cannot modify existing instance
|
||||||
@@ -196,7 +196,8 @@ class CustomUserViewSetTest(APITestCase):
|
|||||||
# Define request data
|
# Define request data
|
||||||
data = {
|
data = {
|
||||||
'email': 'test_alt@email.com',
|
'email': 'test_alt@email.com',
|
||||||
'full_name': 'TEST NAME ALT'
|
'full_name': 'TEST NAME ALT',
|
||||||
|
'notify': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Authenticate user
|
# Authenticate user
|
||||||
@@ -346,6 +347,7 @@ class UpdateUserViewTest(APITestCase):
|
|||||||
"email": "new_email@mail.com",
|
"email": "new_email@mail.com",
|
||||||
"full_name": "New Full Name",
|
"full_name": "New Full Name",
|
||||||
'provider': 'PROVIDER',
|
'provider': 'PROVIDER',
|
||||||
|
'notify': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Authenticate
|
# Authenticate
|
||||||
|
|||||||
Reference in New Issue
Block a user