add receiver_keys to the settings page
This commit is contained in:
parent
25db7c716d
commit
8de70cd523
@ -12,6 +12,7 @@ from owrx.form import (
|
|||||||
Option,
|
Option,
|
||||||
ServicesCheckboxInput,
|
ServicesCheckboxInput,
|
||||||
Js8ProfileCheckboxInput,
|
Js8ProfileCheckboxInput,
|
||||||
|
ReceiverKeysInput,
|
||||||
)
|
)
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
import json
|
import json
|
||||||
@ -100,6 +101,15 @@ class GeneralSettingsController(AdminController):
|
|||||||
TextInput("photo_title", "Photo title"),
|
TextInput("photo_title", "Photo title"),
|
||||||
TextAreaInput("photo_desc", "Photo description"),
|
TextAreaInput("photo_desc", "Photo description"),
|
||||||
),
|
),
|
||||||
|
Section(
|
||||||
|
"Receiver listings",
|
||||||
|
ReceiverKeysInput(
|
||||||
|
"receiver_keys",
|
||||||
|
"Receiver keys",
|
||||||
|
infotext="Put the keys you receive on listing sites (e.g. "
|
||||||
|
+ '<a href="https://www.receiverbook.de">Receiverbook</a>) here, one per line',
|
||||||
|
),
|
||||||
|
),
|
||||||
Section(
|
Section(
|
||||||
"Waterfall settings",
|
"Waterfall settings",
|
||||||
NumberInput(
|
NumberInput(
|
||||||
@ -294,4 +304,4 @@ class GeneralSettingsController(AdminController):
|
|||||||
for k, v in data.items():
|
for k, v in data.items():
|
||||||
config[k] = v
|
config[k] = v
|
||||||
Config.store()
|
Config.store()
|
||||||
self.send_redirect("/admin")
|
self.send_redirect("/generalsettings")
|
||||||
|
@ -30,11 +30,17 @@ class Input(ABC):
|
|||||||
def render_input(self, value):
|
def render_input(self, value):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def convert_to_form(self, value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
def convert_from_form(self, value):
|
||||||
|
return value
|
||||||
|
|
||||||
def render(self, config):
|
def render(self, config):
|
||||||
return self.bootstrap_decorate(self.render_input(config[self.id]))
|
return self.bootstrap_decorate(self.render_input(self.convert_to_form(config[self.id])))
|
||||||
|
|
||||||
def parse(self, data):
|
def parse(self, data):
|
||||||
return {self.id: data[self.id][0]} if self.id in data else {}
|
return {self.id: self.convert_from_form(data[self.id][0])} if self.id in data else {}
|
||||||
|
|
||||||
|
|
||||||
class TextInput(Input):
|
class TextInput(Input):
|
||||||
@ -62,19 +68,16 @@ class NumberInput(Input):
|
|||||||
step='step="{0}"'.format(self.step) if self.step else "",
|
step='step="{0}"'.format(self.step) if self.step else "",
|
||||||
)
|
)
|
||||||
|
|
||||||
def convert_value(self, v):
|
def convert_from_form(self, v):
|
||||||
return int(v)
|
return int(v)
|
||||||
|
|
||||||
def parse(self, data):
|
|
||||||
return {k: self.convert_value(v) for k, v in super().parse(data).items()}
|
|
||||||
|
|
||||||
|
|
||||||
class FloatInput(NumberInput):
|
class FloatInput(NumberInput):
|
||||||
def __init__(self, id, label, infotext=None):
|
def __init__(self, id, label, infotext=None):
|
||||||
super().__init__(id, label, infotext)
|
super().__init__(id, label, infotext)
|
||||||
self.step = "any"
|
self.step = "any"
|
||||||
|
|
||||||
def convert_value(self, v):
|
def convert_from_form(self, v):
|
||||||
return float(v)
|
return float(v)
|
||||||
|
|
||||||
|
|
||||||
@ -118,6 +121,15 @@ class TextAreaInput(Input):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ReceiverKeysInput(TextAreaInput):
|
||||||
|
def convert_to_form(self, value):
|
||||||
|
return "\n".join(value)
|
||||||
|
|
||||||
|
def convert_from_form(self, value):
|
||||||
|
# \r\n or \n? this should work with both.
|
||||||
|
return [v.strip("\r ") for v in value.split("\n")]
|
||||||
|
|
||||||
|
|
||||||
class CheckboxInput(Input):
|
class CheckboxInput(Input):
|
||||||
def __init__(self, id, label, checkboxText, infotext=None):
|
def __init__(self, id, label, checkboxText, infotext=None):
|
||||||
super().__init__(id, label, infotext=infotext)
|
super().__init__(id, label, infotext=infotext)
|
||||||
|
Loading…
Reference in New Issue
Block a user