@@ -177,7 +177,7 @@ def __init__(
177177
178178 def validate_settings (self ):
179179 for setting in self ._project .settings [:]:
180- if setting .attribute == "WorkflowType" :
180+ if setting .attribute not in constances . PROJECT_SETTINGS_VALID_ATTRIBUTES :
181181 self ._project .settings .remove (setting )
182182 if setting .attribute == "ImageQuality" and isinstance (setting .value , str ):
183183 setting .value = constances .ImageQuality .get_value (setting .value )
@@ -335,6 +335,39 @@ def __init__(
335335 self ._project = project
336336 self ._service_provider = service_provider
337337
338+ def validate_settings (self ):
339+ for setting in self ._project .settings [:]:
340+ if setting .attribute not in constances .PROJECT_SETTINGS_VALID_ATTRIBUTES :
341+ self ._project .settings .remove (setting )
342+ if setting .attribute == "ImageQuality" and isinstance (setting .value , str ):
343+ setting .value = constances .ImageQuality .get_value (setting .value )
344+ elif setting .attribute == "FrameRate" :
345+ if not self ._project .type == constances .ProjectType .VIDEO .value :
346+ raise AppValidationException (
347+ "FrameRate is available only for Video projects"
348+ )
349+ try :
350+ setting .value = float (setting .value )
351+ if (
352+ not (0.0001 < setting .value < 120 )
353+ or decimal .Decimal (str (setting .value )).as_tuple ().exponent < - 3
354+ ):
355+ raise AppValidationException (
356+ "The FrameRate value range is between 0.001 - 120"
357+ )
358+ frame_mode = next (
359+ filter (
360+ lambda x : x .attribute == "FrameMode" , self ._project .settings
361+ ),
362+ None ,
363+ )
364+ if not frame_mode :
365+ self ._project .settings .append (
366+ SettingEntity (attribute = "FrameMode" , value = 1 )
367+ )
368+ except ValueError :
369+ raise AppValidationException ("The FrameRate value should be float" )
370+
338371 def validate_project_name (self ):
339372 if self ._project .name :
340373 if (
@@ -488,13 +521,17 @@ def execute(self):
488521
489522 new_settings_to_update = []
490523 for new_setting in self ._to_update :
491- new_settings_to_update .append (
492- SettingEntity (
493- id = attr_id_mapping [new_setting ["attribute" ]],
494- attribute = new_setting ["attribute" ],
495- value = new_setting ["value" ],
524+ if (
525+ new_setting ["attribute" ]
526+ in constances .PROJECT_SETTINGS_VALID_ATTRIBUTES
527+ ):
528+ new_settings_to_update .append (
529+ SettingEntity (
530+ id = attr_id_mapping [new_setting ["attribute" ]],
531+ attribute = new_setting ["attribute" ],
532+ value = new_setting ["value" ],
533+ )
496534 )
497- )
498535
499536 response = self ._service_provider .projects .set_settings (
500537 project = self ._project ,
0 commit comments