File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -923,6 +923,11 @@ def validate_photos(self, photos):
923923 raise serializers .ValidationError ("Can add utmost %s photos" % self .MAX_NUMBER_OF_PHOTOS )
924924 return photos
925925
926+ def validate_type_of_dref (self , type_of_dref ):
927+ if self .instance and self .instance .type_of_dref == Dref .DrefType .LOAN :
928+ raise serializers .ValidationError ("Can't change dref type for %s in Final Report" % Dref .DrefType .LOAN )
929+ return type_of_dref
930+
926931 def create (self , validated_data ):
927932 # here check if there is operational update for corresponding dref
928933 # if yes copy from the latest operational update
Original file line number Diff line number Diff line change @@ -1309,3 +1309,27 @@ def test_dref_share_users(self):
13091309 set (response .data ['results' ][0 ]['users' ]),
13101310 set ([user2 .id , user3 .id , user4 .id ])
13111311 )
1312+
1313+ def test_dref_final_report_change_for_loan_type (self ):
1314+ country_1 = Country .objects .create (name = "country1" )
1315+ dref = DrefFactory .create (
1316+ is_published = True ,
1317+ type_of_dref = Dref .DrefType .LOAN ,
1318+ country = country_1 ,
1319+ created_by = self .root_user
1320+ )
1321+ final_report = DrefFinalReportFactory .create (
1322+ is_published = False ,
1323+ country = country_1 ,
1324+ type_of_dref = Dref .DrefType .LOAN ,
1325+ dref = dref ,
1326+ created_by = self .root_user
1327+ )
1328+ url = f"/api/v2/dref-final-report/{ final_report .id } /"
1329+ data = {
1330+ "type_of_dref" : Dref .DrefType .ASSESSMENT ,
1331+ "modified_at" : datetime .now () + timedelta (days = 1 )
1332+ }
1333+ self .authenticate (self .root_user )
1334+ response = self .client .patch (url , data = data )
1335+ self .assertEqual (response .status_code , 400 )
You can’t perform that action at this time.
0 commit comments