fix - deleted user -> trash=True

This commit is contained in:
2025-10-29 16:59:28 +03:30
parent 3b78560bb9
commit 005039dd54
3 changed files with 16 additions and 9 deletions

View File

@@ -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()