From aeae2ef60ad863865b61f5fe788d19cd061d7472 Mon Sep 17 00:00:00 2001 From: Muhammed Zafar Date: Wed, 27 Dec 2023 01:31:46 +0530 Subject: [PATCH] [MINOR] Some minor changes --- api/dashboard/roles/dash_roles_serializer.py | 6 ++---- db/organization.py | 16 +++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/api/dashboard/roles/dash_roles_serializer.py b/api/dashboard/roles/dash_roles_serializer.py index 8bc02407..e1dea769 100644 --- a/api/dashboard/roles/dash_roles_serializer.py +++ b/api/dashboard/roles/dash_roles_serializer.py @@ -29,8 +29,7 @@ class RoleAssignmentSerializer(serializers.Serializer): role = serializers.PrimaryKeyRelatedField(queryset=Role.objects.all()) users = serializers.ListField(child=serializers.UUIDField()) - created_by = serializers.PrimaryKeyRelatedField( - queryset=User.objects.all()) + created_by = serializers.PrimaryKeyRelatedField(queryset=User.objects.all()) def validate(self, attrs): data = super().validate(attrs) @@ -39,8 +38,7 @@ def validate(self, attrs): ~Q(user_role_link_user__role=data["role"]), pk__in=attrs ) if users.count() != len(attrs): - raise serializers.ValidationError( - "One or more user IDs are invalid.") + raise serializers.ValidationError("One or more user IDs are invalid.") data["users"] = users return data diff --git a/db/organization.py b/db/organization.py index 5dd373f4..7c5bab15 100644 --- a/db/organization.py +++ b/db/organization.py @@ -121,15 +121,13 @@ class Meta: class College(models.Model): - id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4()) - level = models.IntegerField(default=0) - org = models.ForeignKey(Organization, on_delete=models.CASCADE, related_name='college_org', unique=True) - updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', - related_name='college_updated_by') - updated_at = models.DateTimeField(auto_now=True) - created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', - related_name='college_created_by') - created_at = models.DateTimeField(auto_now_add=True) + id = models.CharField(primary_key=True, max_length=36, default=uuid.uuid4()) + level = models.IntegerField(default=0) + org = models.OneToOneField(Organization, on_delete=models.CASCADE, related_name='college_org') + updated_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='updated_by', related_name='college_updated_by') + updated_at = models.DateTimeField(auto_now=True) + created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by', related_name='college_created_by') + created_at = models.DateTimeField(auto_now_add=True) class Meta: managed = False