fix - bug of edit organization by field
This commit is contained in:
@@ -310,7 +310,7 @@ class OrganizationViewSet(BaseViewSet, ModelViewSet, DynamicSearchMixin):
|
||||
serializer = self.get_serializer(
|
||||
instance,
|
||||
data=request.data['organization'],
|
||||
partial=partial
|
||||
partial=True
|
||||
)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
organization = serializer.save()
|
||||
|
||||
@@ -280,7 +280,7 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
|
||||
# check national_unique_id
|
||||
national_unique_id = attrs['national_unique_id']
|
||||
national_unique_id = attrs.get('national_unique_id', 0)
|
||||
|
||||
if not self.instance:
|
||||
if self.Meta.model.objects.filter(national_unique_id=national_unique_id).exists():
|
||||
@@ -292,9 +292,9 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
|
||||
# check organization type field
|
||||
# if is repeatable of type, organization will not be recreating
|
||||
org_type = attrs['type']
|
||||
org_type = attrs.get('type', None)
|
||||
if not self.instance:
|
||||
if not org_type.is_repeatable:
|
||||
if org_type is not None and not org_type.is_repeatable:
|
||||
if org_type.org_type_field == 'PR' and self.Meta.model.objects.filter(
|
||||
type=org_type,
|
||||
province=attrs['province']
|
||||
@@ -315,7 +315,7 @@ class OrganizationSerializer(serializers.ModelSerializer):
|
||||
|
||||
# check organization type field when updating
|
||||
elif self.instance:
|
||||
if not org_type.is_repeatable:
|
||||
if org_type is not None and 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,
|
||||
|
||||
Reference in New Issue
Block a user