diff --git a/owrx/config/migration.py b/owrx/config/migration.py
index 6db096c8..93e52757 100644
--- a/owrx/config/migration.py
+++ b/owrx/config/migration.py
@@ -162,7 +162,11 @@ class Migrator(object):
def migrate(config):
version = config["version"] if "version" in config else 1
if version == Migrator.currentVersion:
- return config
+ return
+ elif version > Migrator.currentVersion:
+ raise ValueError(
+ "Configuration version is too high (current: {}, found: {})".format(Migrator.currentVersion, version)
+ )
logger.debug("migrating config from version %i", version)
migrators = [Migrator.migrators[i] for i in range(version, Migrator.currentVersion)]
diff --git a/owrx/controllers/settings/general.py b/owrx/controllers/settings/general.py
index 231a3c00..e8ccea90 100644
--- a/owrx/controllers/settings/general.py
+++ b/owrx/controllers/settings/general.py
@@ -11,7 +11,7 @@ from owrx.form.input import (
Option,
)
from owrx.form.input.converter import WaterfallColorsConverter, IntConverter
-from owrx.form.input.receiverid import ReceiverKeysConverter
+from owrx.form.input.receiverid import ReceiverKeysInput
from owrx.form.input.gfx import AvatarInput, TopPhotoInput
from owrx.form.input.device import WaterfallLevelsInput, WaterfallAutoLevelsInput
from owrx.form.input.location import LocationInput
@@ -75,12 +75,9 @@ class GeneralSettingsController(SettingsFormController):
),
Section(
"Receiver listings",
- TextAreaInput(
+ ReceiverKeysInput(
"receiver_keys",
"Receiver keys",
- converter=ReceiverKeysConverter(),
- infotext="Put the keys you receive on listing sites (e.g. "
- + 'Receiverbook) here, one per line',
),
),
Section(
diff --git a/owrx/form/input/__init__.py b/owrx/form/input/__init__.py
index 06a3d79c..57e59b7a 100644
--- a/owrx/form/input/__init__.py
+++ b/owrx/form/input/__init__.py
@@ -163,14 +163,19 @@ class FloatInput(NumberInput):
class TextAreaInput(Input):
def render_input(self, value, errors):
return """
-
+
""".format(
- id=self.id,
- classes=self.input_classes(errors),
+ properties=self.render_input_properties(value, errors),
value=value,
- disabled="disabled" if self.disabled else "",
)
+ def input_properties(self, value, errors):
+ props = super().input_properties(value, errors)
+ props["style"] = "height:200px;"
+ # value works differently on textareas
+ del props["value"]
+ return props
+
class CheckboxInput(Input):
def __init__(self, id, checkboxText, infotext=None, converter: Converter = None):
diff --git a/owrx/form/input/receiverid.py b/owrx/form/input/receiverid.py
index 0812cc6d..43c0a5de 100644
--- a/owrx/form/input/receiverid.py
+++ b/owrx/form/input/receiverid.py
@@ -1,3 +1,4 @@
+from owrx.form.input import TextAreaInput
from owrx.form.input.converter import Converter
@@ -7,4 +8,26 @@ class ReceiverKeysConverter(Converter):
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")]
+ stripped = [v.strip("\r ") for v in value.split("\n")]
+ # omit empty lines
+ return [v for v in stripped if v]
+
+
+class ReceiverKeysInput(TextAreaInput):
+ def __init__(self, id, label):
+ super().__init__(
+ id,
+ label,
+ infotext="Put the keys you receive on listing sites (e.g. "
+ + 'Receiverbook) here, one per line',
+ )
+
+ def input_properties(self, value, errors):
+ props = super().input_properties(value, errors)
+ # disable word wrap on the textarea.
+ # why? keys are longer than the input, and word wrap makes the "one per line" instruction confusing.
+ props["wrap"] = "off"
+ return props
+
+ def defaultConverter(self):
+ return ReceiverKeysConverter()