@@ -218,7 +218,7 @@ class MiniFullEAPSerializer(
218218
219219 class Meta :
220220 model = FullEAP
221- fields = [
221+ fields = (
222222 "id" ,
223223 "total_budget" ,
224224 "readiness_budget" ,
@@ -232,7 +232,7 @@ class Meta:
232232 "updated_checklist_file_details" ,
233233 "created_at" ,
234234 "modified_at" ,
235- ]
235+ )
236236
237237
238238class MiniEAPSerializer (serializers .ModelSerializer ):
@@ -574,6 +574,8 @@ class Meta:
574574 read_only_fields = [
575575 "version" ,
576576 "is_locked" ,
577+ "created_by" ,
578+ "modified_by" ,
577579 ]
578580 exclude = ("cover_image" ,)
579581
@@ -626,6 +628,11 @@ def _validate_timeframe(self, data: dict[str, typing.Any]) -> None:
626628 {"operational_timeframe" : gettext ("operational timeframe value is not valid for Months unit." )}
627629 )
628630
631+ def validate_eap_registration (self , eap_registration : EAPRegistration ) -> EAPRegistration :
632+ if not self .instance and eap_registration .has_eap_application :
633+ raise serializers .ValidationError ("EAP for this registration has already been created." )
634+ return eap_registration
635+
629636 def validate (self , data : dict [str , typing .Any ]) -> dict [str , typing .Any ]:
630637 original_eap_registration = getattr (self .instance , "eap_registration" , None ) if self .instance else None
631638 eap_registration : EAPRegistration | None = data .get ("eap_registration" , original_eap_registration )
@@ -634,9 +641,6 @@ def validate(self, data: dict[str, typing.Any]) -> dict[str, typing.Any]:
634641 if self .instance and original_eap_registration != eap_registration :
635642 raise serializers .ValidationError ("EAP Registration cannot be changed for existing EAP." )
636643
637- if not self .instance and eap_registration .has_eap_application :
638- raise serializers .ValidationError ("Simplified EAP for this EAP registration already exists." )
639-
640644 if self .instance and eap_registration .get_status_enum not in [
641645 EAPRegistration .Status .UNDER_DEVELOPMENT ,
642646 EAPRegistration .Status .NS_ADDRESSING_COMMENTS ,
@@ -777,10 +781,12 @@ class FullEAPSerializer(
777781
778782 class Meta :
779783 model = FullEAP
780- read_only_fields = (
784+ read_only_fields = [
785+ "version" ,
786+ "is_locked" ,
781787 "created_by" ,
782788 "modified_by" ,
783- )
789+ ]
784790 exclude = ("cover_image" ,)
785791
786792 def _validate_timeframe (self , data : dict [str , typing .Any ]) -> None :
@@ -794,11 +800,13 @@ def _validate_timeframe(self, data: dict[str, typing.Any]) -> None:
794800 }
795801 )
796802
797- if lead_unit is not None and lead_time_value is not None :
798- if lead_unit != TimeFrame .DAYS :
799- raise serializers .ValidationError (
800- {"lead_timeframe_unit" : gettext ("lead timeframe unit must be Days for Full EAP." )}
801- )
803+ if lead_unit is not None and lead_time_value is not None and lead_unit != TimeFrame .DAYS :
804+ raise serializers .ValidationError ({"lead_timeframe_unit" : gettext ("lead timeframe unit must be Days for Full EAP." )})
805+
806+ def validate_eap_registration (self , eap_registration : EAPRegistration ) -> EAPRegistration :
807+ if not self .instance and eap_registration .has_eap_application :
808+ raise serializers .ValidationError ("EAP for this registration has already been created." )
809+ return eap_registration
802810
803811 def validate (self , data : dict [str , typing .Any ]) -> dict [str , typing .Any ]:
804812 original_eap_registration = getattr (self .instance , "eap_registration" , None ) if self .instance else None
@@ -808,9 +816,6 @@ def validate(self, data: dict[str, typing.Any]) -> dict[str, typing.Any]:
808816 if self .instance and original_eap_registration != eap_registration :
809817 raise serializers .ValidationError ("EAP Registration cannot be changed for existing EAP." )
810818
811- if not self .instance and eap_registration .has_eap_application :
812- raise serializers .ValidationError ("Full EAP for this EAP registration already exists." )
813-
814819 if self .instance and eap_registration .get_status_enum not in [
815820 EAPRegistration .Status .UNDER_DEVELOPMENT ,
816821 EAPRegistration .Status .NS_ADDRESSING_COMMENTS ,
0 commit comments