diff --git a/caimira/apps/calculator/model_generator.py b/caimira/apps/calculator/model_generator.py index cedcbb39..6b9a6796 100644 --- a/caimira/apps/calculator/model_generator.py +++ b/caimira/apps/calculator/model_generator.py @@ -43,7 +43,7 @@ class FormData: floor_area: float hepa_amount: float hepa_option: bool - humidity: float + humidity: str infected_coffee_break_option: str #Used if infected_dont_have_breaks_with_exposed infected_coffee_duration: int #Used if infected_dont_have_breaks_with_exposed infected_dont_have_breaks_with_exposed: bool @@ -102,7 +102,7 @@ class FormData: 'floor_area': 0., 'hepa_amount': 0., 'hepa_option': False, - 'humidity': _NO_DEFAULT, + 'humidity': '', 'infected_coffee_break_option': 'coffee_break_0', 'infected_coffee_duration': 5, 'infected_dont_have_breaks_with_exposed': False, @@ -299,7 +299,7 @@ class FormData: humidity = 0.5 inside_temp = 293. else: - humidity = self.humidity + humidity = float(self.humidity) inside_temp = self.inside_temp room = models.Room(volume=volume, inside_temp=models.PiecewiseConstant((0, 24), (inside_temp,)), humidity=humidity) diff --git a/caimira/apps/calculator/static/js/form.js b/caimira/apps/calculator/static/js/form.js index ffa0f4f4..ca89fac0 100644 --- a/caimira/apps/calculator/static/js/form.js +++ b/caimira/apps/calculator/static/js/form.js @@ -278,13 +278,6 @@ function populate_temp_hum_values(data, index) { $("[name='humidity']").val(data[index].Details.RH/100); }; -function clear_sensors_data() { - $("#sensor_temperature").text(); - $("#sensor_humidity").text(); - $("[name='inside_temp']").val(); - $("[name='humidity']").val(); -} - //Data from ARVE sensors var DATA_FROM_SENSORS; function show_sensors_data(url) { @@ -332,7 +325,6 @@ function on_use_sensors_data_change(url) { } else { getChildElement($(this)).hide(); - clear_sensors_data(); } }) } @@ -470,6 +462,11 @@ function validate_form(form) { }); } + // Logic for the API requests. Always set humity input as the empty string so that we can profit from the "room_heating_option default" values for humidity. + if ($("#arve_sensor_no").prop('checked')) { + $("[name='humidity']").val(''); + } + // Validate location input. if (submit) { // We make the non-visible location inputs mandatory, without marking them as "required" inputs. @@ -813,11 +810,13 @@ $(document).ready(function () { //Check all radio buttons previously selected $("input[type=radio]:checked").each(function() {require_fields(this)}); - // When the arve_sensors_option changes we want to make its respective + // On CERN theme, When the arve_sensors_option changes we want to make its respective // children show/hide. - $("input[type=radio][name=arve_sensors_option]").change(on_use_sensors_data_change); - // Call the function now to handle forward/back button presses in the browser. - on_use_sensors_data_change(url); + if ($("input[type=radio][name=arve_sensors_option]").length > 0) { + $("input[type=radio][name=arve_sensors_option]").change(on_use_sensors_data_change); + // Call the function now to handle forward/back button presses in the browser. + on_use_sensors_data_change(url); + } // When the ventilation_type changes we want to make its respective // children show/hide. @@ -917,9 +916,6 @@ $(document).ready(function () { templateSelection: formatLocationSelection }); - // Logic for the API requests. Always set humity input as the empty string so that we can profit from the "room_heating_option default" values for humidity. - $("[name='humidity']").val(""); - function formatlocation(suggestedLocation) { // Function is called for each location from the geocoding API.