add optional aprs fields and todos
This commit is contained in:
		@@ -16,6 +16,7 @@ from owrx.form import (
 | 
				
			|||||||
    WfmTauValues,
 | 
					    WfmTauValues,
 | 
				
			||||||
    WfmTauConverter,
 | 
					    WfmTauConverter,
 | 
				
			||||||
    MultiCheckboxInput,
 | 
					    MultiCheckboxInput,
 | 
				
			||||||
 | 
					    OptionalConverter,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
from urllib.parse import quote
 | 
					from urllib.parse import quote
 | 
				
			||||||
from owrx.wsjt import Fst4Profile, Fst4wProfile
 | 
					from owrx.wsjt import Fst4Profile, Fst4wProfile
 | 
				
			||||||
@@ -237,7 +238,8 @@ class GeneralSettingsController(AdminController):
 | 
				
			|||||||
                "fst4w_enabled_intervals",
 | 
					                "fst4w_enabled_intervals",
 | 
				
			||||||
                "Enabled FST4W intervals",
 | 
					                "Enabled FST4W intervals",
 | 
				
			||||||
                [Option(v, "{}s".format(v)) for v in Fst4wProfile.availableIntervals],
 | 
					                [Option(v, "{}s".format(v)) for v in Fst4wProfile.availableIntervals],
 | 
				
			||||||
            )
 | 
					            ),
 | 
				
			||||||
 | 
					            # TODO: q65_enabled_combinations
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        Section(
 | 
					        Section(
 | 
				
			||||||
            "Background decoding",
 | 
					            "Background decoding",
 | 
				
			||||||
@@ -258,7 +260,7 @@ class GeneralSettingsController(AdminController):
 | 
				
			|||||||
            CheckboxInput(
 | 
					            CheckboxInput(
 | 
				
			||||||
                "aprs_igate_enabled",
 | 
					                "aprs_igate_enabled",
 | 
				
			||||||
                "APRS I-Gate",
 | 
					                "APRS I-Gate",
 | 
				
			||||||
                checkboxText="Enable APRS receive-only I-Gate",
 | 
					                checkboxText="Send received APRS data to APRS-IS",
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
            TextInput("aprs_igate_server", "APRS-IS server"),
 | 
					            TextInput("aprs_igate_server", "APRS-IS server"),
 | 
				
			||||||
            TextInput("aprs_igate_password", "APRS-IS network password"),
 | 
					            TextInput("aprs_igate_password", "APRS-IS network password"),
 | 
				
			||||||
@@ -268,6 +270,27 @@ class GeneralSettingsController(AdminController):
 | 
				
			|||||||
                checkboxText="Send the receiver position to the APRS-IS network",
 | 
					                checkboxText="Send the receiver position to the APRS-IS network",
 | 
				
			||||||
                infotext="Please check that your receiver location is setup correctly",
 | 
					                infotext="Please check that your receiver location is setup correctly",
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
 | 
					            # TODO: aprs_igate_symbol
 | 
				
			||||||
 | 
					            TextInput(
 | 
				
			||||||
 | 
					                "aprs_igate_comment",
 | 
				
			||||||
 | 
					                "APRS beacon text",
 | 
				
			||||||
 | 
					                infotext="This text will be sent as APRS comment along with your beacon",
 | 
				
			||||||
 | 
					                converter=OptionalConverter(),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            NumberInput(
 | 
				
			||||||
 | 
					                "aprs_igate_height",
 | 
				
			||||||
 | 
					                "Antenna height",
 | 
				
			||||||
 | 
					                infotext="Antenna height above average terrain (HAAT)",
 | 
				
			||||||
 | 
					                append="m",
 | 
				
			||||||
 | 
					                converter=OptionalConverter(),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            NumberInput(
 | 
				
			||||||
 | 
					                "aprs_igate_gain",
 | 
				
			||||||
 | 
					                "Antenna gain",
 | 
				
			||||||
 | 
					                append="dBi",
 | 
				
			||||||
 | 
					                converter=OptionalConverter(),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					            # TODO: aprs_igate_dir
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        Section(
 | 
					        Section(
 | 
				
			||||||
            "pskreporter settings",
 | 
					            "pskreporter settings",
 | 
				
			||||||
@@ -281,6 +304,12 @@ class GeneralSettingsController(AdminController):
 | 
				
			|||||||
                "pskreporter callsign",
 | 
					                "pskreporter callsign",
 | 
				
			||||||
                infotext="This callsign will be used to send spots to pskreporter.info",
 | 
					                infotext="This callsign will be used to send spots to pskreporter.info",
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
 | 
					            TextInput(
 | 
				
			||||||
 | 
					                "pskreporter_antenna_information",
 | 
				
			||||||
 | 
					                "Antenna information",
 | 
				
			||||||
 | 
					                infotext="Antenna description to be sent along with spots to pskreporter",
 | 
				
			||||||
 | 
					                converter=OptionalConverter(),
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        Section(
 | 
					        Section(
 | 
				
			||||||
            "WSPRnet settings",
 | 
					            "WSPRnet settings",
 | 
				
			||||||
@@ -319,7 +348,7 @@ class GeneralSettingsController(AdminController):
 | 
				
			|||||||
        return variables
 | 
					        return variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def processFormData(self):
 | 
					    def processFormData(self):
 | 
				
			||||||
        data = parse_qs(self.get_body().decode("utf-8"))
 | 
					        data = parse_qs(self.get_body().decode("utf-8"), keep_blank_values=True)
 | 
				
			||||||
        data = {k: v for i in GeneralSettingsController.sections for k, v in i.parse(data).items()}
 | 
					        data = {k: v for i in GeneralSettingsController.sections for k, v in i.parse(data).items()}
 | 
				
			||||||
        config = Config.get()
 | 
					        config = Config.get()
 | 
				
			||||||
        for k, v in data.items():
 | 
					        for k, v in data.items():
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,19 @@ class NullConverter(Converter):
 | 
				
			|||||||
        return value
 | 
					        return value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class OptionalConverter(Converter):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Maps None to an empty string, and reverse
 | 
				
			||||||
 | 
					    useful for optional fields
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def convert_to_form(self, value):
 | 
				
			||||||
 | 
					        return "" if value is None else value
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def convert_from_form(self, value):
 | 
				
			||||||
 | 
					        return value if value else None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Input(ABC):
 | 
					class Input(ABC):
 | 
				
			||||||
    def __init__(self, id, label, infotext=None, converter: Converter = None):
 | 
					    def __init__(self, id, label, infotext=None, converter: Converter = None):
 | 
				
			||||||
        self.id = id
 | 
					        self.id = id
 | 
				
			||||||
@@ -54,7 +67,8 @@ class Input(ABC):
 | 
				
			|||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def render(self, config):
 | 
					    def render(self, config):
 | 
				
			||||||
        return self.bootstrap_decorate(self.render_input(self.converter.convert_to_form(config[self.id])))
 | 
					        value = config[self.id] if self.id in config else None
 | 
				
			||||||
 | 
					        return self.bootstrap_decorate(self.render_input(self.converter.convert_to_form(value)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def parse(self, data):
 | 
					    def parse(self, data):
 | 
				
			||||||
        return {self.id: self.converter.convert_from_form(data[self.id][0])} if self.id in data else {}
 | 
					        return {self.id: self.converter.convert_from_form(data[self.id][0])} if self.id in data else {}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user