from owrx.form import Input class GainInput(Input): def render_input(self, value): auto_mode = value is None or value == "auto" return """
""".format( id=self.id, classes=self.input_classes(), value=value, label=self.label, auto_selected="selected" if auto_mode else "", manual_selected="" if auto_mode else "selected", ) def parse(self, data): select_id = "{id}-select".format(id=self.id) if select_id in data: input_id = "{id}-manual".format(id=self.id) if data[select_id][0] == "manual" and input_id in data: return {self.id: float(data[input_id][0])} return {self.id: None}