diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 4dd7be70..bd2114d5 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -76,7 +76,12 @@ class FormData: if form_data[key] not in valid_set: raise ValueError(f"{form_data[key]} is not a valid value for {key}") - # Don't let arbirtrary unescaped HTML through the net. + if (form_data['ventilation_type'] == 'natural' and + form_data['window_type'] == 'not-applicable'): + raise ValueError("window_type cannot be ''not-applicable'' if " + "ventilation_type is ''natural''") + + # Don't let arbitrary unescaped HTML through the net. for key, value in form_data.items(): if isinstance(value, str): form_data[key] = html.escape(value) diff --git a/cara/models.py b/cara/models.py index 66234a26..4478c1ce 100644 --- a/cara/models.py +++ b/cara/models.py @@ -260,6 +260,10 @@ class HingedWindow(WindowOpening): #: Window width (m). window_width: float = None + def __post_init__(self): + if self.window_width is None: + raise ValueError('window_width must be set') + @property def discharge_coefficient(self) -> float: """ @@ -284,7 +288,7 @@ class HingedWindow(WindowOpening): else: M = 0.038 cd_max = 0.548 - window_angle = 2.*np.arcsin(self.opening_length/(2.*self.window_height))*180/np.pi + window_angle = 2.*np.rad2deg(np.arcsin(self.opening_length/(2.*self.window_height))) return cd_max*(1-np.exp(-M*window_angle))