perf: 移除资源创建时对于Auditor用户的限制

pull/5674/head
Bai 4 years ago committed by 老广
parent 1d15f7125e
commit 56328e112a

@ -28,12 +28,3 @@ class UserUserGroupRelationViewSet(JMSBulkRelationModelViewSet):
return False return False
else: else:
return True 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)

@ -53,7 +53,3 @@ class UserGroupSerializer(BulkOrgResourceModelSerializer):
Prefetch('users', queryset=User.objects.only('id')) Prefetch('users', queryset=User.objects.only('id'))
).annotate(users_amount=Count('users')) ).annotate(users_amount=Count('users'))
return queryset return queryset
def validate_users(self, users):
users = [user for user in users if user.role != User.ROLE.AUDITOR]
return users

@ -113,17 +113,6 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
raise serializers.ValidationError(msg) raise serializers.ValidationError(msg)
return password 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 @staticmethod
def change_password_to_raw(attrs): def change_password_to_raw(attrs):
password = attrs.pop('password', None) password = attrs.pop('password', None)

Loading…
Cancel
Save