@@ -1357,6 +1357,12 @@ def __init__(
13571357 self ._project_id = project_id
13581358 self ._team_id = team_id
13591359
1360+ def validate_image_quality (self ):
1361+ for setting in self ._to_update :
1362+ if setting ["attribute" ].lower () == "imagequality" and isinstance (setting ["value" ], str ):
1363+ setting ["value" ] = constances .ImageQuality .get_value (setting ["value" ])
1364+ return
1365+
13601366 def validate_project_type (self ):
13611367 project = self ._projects .get_one (uuid = self ._project_id , team_id = self ._team_id )
13621368 for attribute in self ._to_update :
@@ -1369,27 +1375,27 @@ def validate_project_type(self):
13691375 )
13701376
13711377 def execute (self ):
1378+ if self .is_valid ():
1379+ old_settings = self ._settings .get_all ()
1380+ attr_id_mapping = {}
1381+ for setting in old_settings :
1382+ attr_id_mapping [setting .attribute ] = setting .uuid
1383+
1384+ new_settings_to_update = []
1385+ for new_setting in self ._to_update :
1386+ new_settings_to_update .append (
1387+ {
1388+ "id" : attr_id_mapping [new_setting ["attribute" ]],
1389+ "attribute" : new_setting ["attribute" ],
1390+ "value" : new_setting ["value" ],
1391+ }
1392+ )
13721393
1373- old_settings = self ._settings .get_all ()
1374- attr_id_mapping = {}
1375- for setting in old_settings :
1376- attr_id_mapping [setting .attribute ] = setting .uuid
1377-
1378- new_settings_to_update = []
1379- for new_setting in self ._to_update :
1380- new_settings_to_update .append (
1381- {
1382- "id" : attr_id_mapping [new_setting ["attribute" ]],
1383- "attribute" : new_setting ["attribute" ],
1384- "value" : new_setting ["value" ],
1385- }
1394+ self ._response .data = self ._backend_service_provider .set_project_settings (
1395+ project_id = self ._project_id ,
1396+ team_id = self ._team_id ,
1397+ data = new_settings_to_update ,
13861398 )
1387-
1388- self ._response .data = self ._backend_service_provider .set_project_settings (
1389- project_id = self ._project_id ,
1390- team_id = self ._team_id ,
1391- data = new_settings_to_update ,
1392- )
13931399 return self ._response
13941400
13951401
@@ -2418,6 +2424,10 @@ def __init__(
24182424 self ._folder = folder
24192425 self ._with_all_sub_folders = with_all_sub_folders
24202426
2427+ def validate_user_input (self ):
2428+ if not self ._folder .name == "root" and self ._with_all_sub_folders :
2429+ raise AppValidationException ("The folder does not contain any sub-folders." )
2430+
24212431 def validate_project_type (self ):
24222432 if self ._project .project_type == constances .ProjectType .VIDEO .value :
24232433 raise AppValidationException (
@@ -2430,13 +2440,16 @@ def execute(self):
24302440 project_id = self ._project .uuid , team_id = self ._project .team_id
24312441 )
24322442 count = 0
2433- for i in data ["folders" ]["data" ]:
2434- if i ["id" ] == self ._folder .uuid :
2435- count = i ["imagesCount" ]
2436-
2437- if self ._with_all_sub_folders :
2443+ if self ._folder .name == "root" :
2444+ count += data ["images" ]["count" ]
2445+ if self ._with_all_sub_folders :
2446+ for i in data ["folders" ]["data" ]:
2447+ count += i ["imagesCount" ]
2448+ else :
24382449 for i in data ["folders" ]["data" ]:
2439- count += i ["imagesCount" ]
2450+ if i ["id" ] == self ._folder .uuid :
2451+ count = i ["imagesCount" ]
2452+
24402453 self ._response .data = count
24412454 return self ._response
24422455
0 commit comments