diff --git a/apps/users/api/relation.py b/apps/users/api/relation.py index 050d9e4e6..c3da7816e 100644 --- a/apps/users/api/relation.py +++ b/apps/users/api/relation.py @@ -28,12 +28,3 @@ class UserUserGroupRelationViewSet(JMSBulkRelationModelViewSet): return False else: return True - - def perform_create(self, serializer): - validated_data = [] - for item in serializer.validated_data: - if item['user'].role == User.ROLE.AUDITOR: - continue - validated_data.append(item) - serializer._validated_data = validated_data - return super().perform_create(serializer) diff --git a/apps/users/serializers/group.py b/apps/users/serializers/group.py index b7a6d204c..41d2282a8 100644 --- a/apps/users/serializers/group.py +++ b/apps/users/serializers/group.py @@ -53,7 +53,3 @@ class UserGroupSerializer(BulkOrgResourceModelSerializer): Prefetch('users', queryset=User.objects.only('id')) ).annotate(users_amount=Count('users')) return queryset - - def validate_users(self, users): - users = [user for user in users if user.role != User.ROLE.AUDITOR] - return users diff --git a/apps/users/serializers/user.py b/apps/users/serializers/user.py index 239b80af1..44264bdb8 100644 --- a/apps/users/serializers/user.py +++ b/apps/users/serializers/user.py @@ -113,17 +113,6 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer): raise serializers.ValidationError(msg) return password - def validate_groups(self, groups): - """ - 审计员不能加入到组中 - """ - role = self.initial_data.get('role') - if self.instance: - role = role or self.instance.role - if role == User.ROLE.AUDITOR: - return [] - return groups - @staticmethod def change_password_to_raw(attrs): password = attrs.pop('password', None)