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

@@ -174,6 +174,8 @@ class UserViewSet(SoftDeleteMixin, ModelViewSet):
else: else:
user_relations.soft_delete() user_relations.soft_delete()
user.soft_delete()
return Response(status=status.HTTP_204_NO_CONTENT) return Response(status=status.HTTP_204_NO_CONTENT)

View File

@@ -113,18 +113,19 @@ class UserSerializer(serializers.ModelSerializer):
if not self.instance: if not self.instance:
if self.Meta.model.objects.filter( if self.Meta.model.objects.filter(
Q(mobile=mobile) | Q(username=attrs['username']) Q(mobile=mobile) | Q(username=attrs['username']),
trash=False
).exists(): ).exists():
raise UserExistException() raise UserExistException()
elif self.instance: elif self.instance:
if self.instance.mobile != mobile: 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() raise UserExistException()
if 'username' in attrs.keys(): if 'username' in attrs.keys():
if self.instance.username != attrs['username']: 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() raise UserExistException()
return attrs return attrs
@@ -272,22 +273,22 @@ class OrganizationSerializer(serializers.ModelSerializer):
if not org_type.is_repeatable: if not org_type.is_repeatable:
if org_type.org_type_field == 'PR' and self.instance.province != attrs[ if org_type.org_type_field == 'PR' and self.instance.province != attrs[
'province'] and self.Meta.model.objects.filter( 'province'] and self.Meta.model.objects.filter(
type=org_type, type=org_type,
province=attrs['province'], province=attrs['province'],
).exists(): ).exists():
raise OrganizationTypeRepeatableException() raise OrganizationTypeRepeatableException()
if org_type.org_type_field == 'CI' and self.instance.city != attrs[ if org_type.org_type_field == 'CI' and self.instance.city != attrs[
'city'] and self.Meta.model.objects.filter( 'city'] and self.Meta.model.objects.filter(
type=org_type, type=org_type,
city=attrs['city'], city=attrs['city'],
).exists(): ).exists():
raise OrganizationTypeRepeatableException() raise OrganizationTypeRepeatableException()
if org_type.org_type_field == 'CO' and self.instance.province != attrs[ if org_type.org_type_field == 'CO' and self.instance.province != attrs[
'province'] and self.Meta.model.objects.filter( 'province'] and self.Meta.model.objects.filter(
type=org_type, type=org_type,
province=attrs['province'], province=attrs['province'],
).exists(): ).exists():
raise OrganizationTypeRepeatableException() raise OrganizationTypeRepeatableException()

View File

@@ -580,3 +580,7 @@ AssertionError: .validate() should return the validated data
[2025-10-29 10:40:10,133] INFO django.server | IP: - | Path: - | "GET /auth/api/v1/organization-type/?org_type_field=PR HTTP/1.1" 200 400 [2025-10-29 10:40:10,133] INFO django.server | IP: - | Path: - | "GET /auth/api/v1/organization-type/?org_type_field=PR HTTP/1.1" 200 400
[2025-10-29 10:40:16,966] INFO django.server | IP: - | Path: - | "GET /auth/api/v1/organization-type/?org_type_field=CO HTTP/1.1" 200 276 [2025-10-29 10:40:16,966] INFO django.server | IP: - | Path: - | "GET /auth/api/v1/organization-type/?org_type_field=CO HTTP/1.1" 200 276
[2025-10-29 16:36:54,591] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading. [2025-10-29 16:36:54,591] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading.
[2025-10-29 16:36:58,756] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
[2025-10-29 16:57:50,609] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading.
[2025-10-29 16:57:52,543] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader
[2025-10-29 16:57:57,860] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\api\v1\serializers\serializer.py changed, reloading.