use a converter -> parsing done
This commit is contained in:
parent
1112334ea8
commit
c2617fcfaf
@ -1,4 +1,5 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class Converter(ABC):
|
class Converter(ABC):
|
||||||
@ -59,3 +60,9 @@ class EnumConverter(Converter):
|
|||||||
return self.enumCls[value].value
|
return self.enumCls[value].value
|
||||||
|
|
||||||
|
|
||||||
|
class JsonConverter(Converter):
|
||||||
|
def convert_to_form(self, value):
|
||||||
|
return json.dumps(value)
|
||||||
|
|
||||||
|
def convert_from_form(self, value):
|
||||||
|
return json.loads(value)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from owrx.form import Input
|
from owrx.form import Input
|
||||||
|
from owrx.form.converter import JsonConverter
|
||||||
from owrx.wsjt import Q65Mode, Q65Interval
|
from owrx.wsjt import Q65Mode, Q65Interval
|
||||||
from owrx.modes import Modes, WsjtMode
|
from owrx.modes import Modes, WsjtMode
|
||||||
import json
|
import json
|
||||||
@ -56,6 +57,9 @@ class Q65ModeMatrix(Input):
|
|||||||
|
|
||||||
|
|
||||||
class WsjtDecodingDepthsInput(Input):
|
class WsjtDecodingDepthsInput(Input):
|
||||||
|
def defaultConverter(self):
|
||||||
|
return JsonConverter()
|
||||||
|
|
||||||
def render_input(self, value):
|
def render_input(self, value):
|
||||||
def render_mode(m):
|
def render_mode(m):
|
||||||
return """
|
return """
|
||||||
@ -74,7 +78,7 @@ class WsjtDecodingDepthsInput(Input):
|
|||||||
""".format(
|
""".format(
|
||||||
id=self.id,
|
id=self.id,
|
||||||
classes=self.input_classes(),
|
classes=self.input_classes(),
|
||||||
value=html.escape(json.dumps(value)),
|
value=html.escape(value),
|
||||||
options="".join(render_mode(m) for m in Modes.getAvailableModes() if isinstance(m, WsjtMode)),
|
options="".join(render_mode(m) for m in Modes.getAvailableModes() if isinstance(m, WsjtMode)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user