fix - deleted user -> trash=True
This commit is contained in:
@@ -174,6 +174,8 @@ class UserViewSet(SoftDeleteMixin, ModelViewSet):
|
||||
else:
|
||||
user_relations.soft_delete()
|
||||
|
||||
user.soft_delete()
|
||||
|
||||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
|
||||
@@ -113,18 +113,19 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
|
||||
if not self.instance:
|
||||
if self.Meta.model.objects.filter(
|
||||
Q(mobile=mobile) | Q(username=attrs['username'])
|
||||
Q(mobile=mobile) | Q(username=attrs['username']),
|
||||
trash=False
|
||||
).exists():
|
||||
raise UserExistException()
|
||||
|
||||
elif self.instance:
|
||||
if self.instance.mobile != mobile:
|
||||
if self.Meta.model.objects.filter(mobile=mobile).exists():
|
||||
if self.Meta.model.objects.filter(trash=False, mobile=mobile).exists():
|
||||
raise UserExistException()
|
||||
|
||||
if 'username' in attrs.keys():
|
||||
if self.instance.username != attrs['username']:
|
||||
if self.Meta.model.objects.filter(username=attrs['username']).exists():
|
||||
if self.Meta.model.objects.filter(trash=False, username=attrs['username']).exists():
|
||||
raise UserExistException()
|
||||
|
||||
return attrs
|
||||
@@ -272,22 +273,22 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
if not org_type.is_repeatable:
|
||||
if org_type.org_type_field == 'PR' and self.instance.province != attrs[
|
||||
'province'] and self.Meta.model.objects.filter(
|
||||
type=org_type,
|
||||
province=attrs['province'],
|
||||
type=org_type,
|
||||
province=attrs['province'],
|
||||
).exists():
|
||||
raise OrganizationTypeRepeatableException()
|
||||
|
||||
if org_type.org_type_field == 'CI' and self.instance.city != attrs[
|
||||
'city'] and self.Meta.model.objects.filter(
|
||||
type=org_type,
|
||||
city=attrs['city'],
|
||||
type=org_type,
|
||||
city=attrs['city'],
|
||||
).exists():
|
||||
raise OrganizationTypeRepeatableException()
|
||||
|
||||
if org_type.org_type_field == 'CO' and self.instance.province != attrs[
|
||||
'province'] and self.Meta.model.objects.filter(
|
||||
type=org_type,
|
||||
province=attrs['province'],
|
||||
type=org_type,
|
||||
province=attrs['province'],
|
||||
).exists():
|
||||
raise OrganizationTypeRepeatableException()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user