@@ -235,6 +235,12 @@ def get_location_geojson(self, unit) -> dict:
235235 return json .loads (unit .location .geojson )
236236
237237
238+ """
239+ NOTE: This `PrivateLocalUnitDetailSerializer` is used to store the previous_data of local unit
240+ changing the serializer might effect the data of previous_data
241+ """
242+
243+
238244class PrivateLocalUnitDetailSerializer (NestedCreateMixin , NestedUpdateMixin ):
239245 country_details = LocalUnitCountrySerializer (source = "country" , read_only = True )
240246 type_details = LocalUnitTypeSerializer (source = "type" , read_only = True )
@@ -537,24 +543,27 @@ class RejectedReasonSerialzier(serializers.Serializer):
537543
538544
539545class LocalUnitChangeRequestSerializer (serializers .ModelSerializer ):
540- local_unit_details = PrivateLocalUnitDetailSerializer (source = "local_unit" , read_only = True )
541546 created_by_details = LocalUnitMiniUserSerializer (source = "created_by" , read_only = True )
542547 status_details = serializers .CharField (source = "get_status_display" , read_only = True )
543548 current_validator_details = serializers .CharField (source = "get_current_validator_display" , read_only = True )
549+ # NOTE: Typing issue on JsonField, So returning as string
550+ previous_data_details = serializers .SerializerMethodField (read_only = True )
544551
545552 class Meta :
546553 model = LocalUnitChangeRequest
547554 fields = (
548555 "id" ,
549- "local_unit_details" ,
550556 "status" ,
551557 "status_details" ,
552558 "current_validator" ,
553559 "current_validator_details" ,
554560 "created_by_details" ,
555- "previous_data " ,
561+ "previous_data_details " ,
556562 )
557563
564+ def get_previous_data_details (self , obj ):
565+ return obj .previous_data
566+
558567
559568class LocalUnitDeprecateSerializer (serializers .ModelSerializer ):
560569 deprecated_reason = serializers .ChoiceField (choices = LocalUnit .DeprecateReason , required = True )
0 commit comments