add optional aprs fields and todos
This commit is contained in:
		@@ -16,6 +16,7 @@ from owrx.form import (
 | 
			
		||||
    WfmTauValues,
 | 
			
		||||
    WfmTauConverter,
 | 
			
		||||
    MultiCheckboxInput,
 | 
			
		||||
    OptionalConverter,
 | 
			
		||||
)
 | 
			
		||||
from urllib.parse import quote
 | 
			
		||||
from owrx.wsjt import Fst4Profile, Fst4wProfile
 | 
			
		||||
@@ -237,7 +238,8 @@ class GeneralSettingsController(AdminController):
 | 
			
		||||
                "fst4w_enabled_intervals",
 | 
			
		||||
                "Enabled FST4W intervals",
 | 
			
		||||
                [Option(v, "{}s".format(v)) for v in Fst4wProfile.availableIntervals],
 | 
			
		||||
            )
 | 
			
		||||
            ),
 | 
			
		||||
            # TODO: q65_enabled_combinations
 | 
			
		||||
        ),
 | 
			
		||||
        Section(
 | 
			
		||||
            "Background decoding",
 | 
			
		||||
@@ -258,7 +260,7 @@ class GeneralSettingsController(AdminController):
 | 
			
		||||
            CheckboxInput(
 | 
			
		||||
                "aprs_igate_enabled",
 | 
			
		||||
                "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_password", "APRS-IS network password"),
 | 
			
		||||
@@ -268,6 +270,27 @@ class GeneralSettingsController(AdminController):
 | 
			
		||||
                checkboxText="Send the receiver position to the APRS-IS network",
 | 
			
		||||
                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(
 | 
			
		||||
            "pskreporter settings",
 | 
			
		||||
@@ -281,6 +304,12 @@ class GeneralSettingsController(AdminController):
 | 
			
		||||
                "pskreporter callsign",
 | 
			
		||||
                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(
 | 
			
		||||
            "WSPRnet settings",
 | 
			
		||||
@@ -319,7 +348,7 @@ class GeneralSettingsController(AdminController):
 | 
			
		||||
        return variables
 | 
			
		||||
 | 
			
		||||
    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()}
 | 
			
		||||
        config = Config.get()
 | 
			
		||||
        for k, v in data.items():
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,19 @@ class NullConverter(Converter):
 | 
			
		||||
        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):
 | 
			
		||||
    def __init__(self, id, label, infotext=None, converter: Converter = None):
 | 
			
		||||
        self.id = id
 | 
			
		||||
@@ -54,7 +67,8 @@ class Input(ABC):
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    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):
 | 
			
		||||
        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