mirror of
https://github.com/jketterl/openwebrx.git
synced 2025-12-06 07:12:09 +01:00
34 lines
978 B
Python
34 lines
978 B
Python
|
|
from owrx.config import Config
|
||
|
|
from owrx.controllers.admin import AuthorizationMixin
|
||
|
|
from owrx.controllers.template import WebpageController
|
||
|
|
|
||
|
|
|
||
|
|
class Section(object):
|
||
|
|
def __init__(self, title, *inputs):
|
||
|
|
self.title = title
|
||
|
|
self.inputs = inputs
|
||
|
|
|
||
|
|
def render_inputs(self):
|
||
|
|
config = Config.get()
|
||
|
|
return "".join([i.render(config) for i in self.inputs])
|
||
|
|
|
||
|
|
def render(self):
|
||
|
|
return """
|
||
|
|
<div class="col-12 settings-section">
|
||
|
|
<h3 class="settings-header">
|
||
|
|
{title}
|
||
|
|
</h3>
|
||
|
|
{inputs}
|
||
|
|
</div>
|
||
|
|
""".format(
|
||
|
|
title=self.title, inputs=self.render_inputs()
|
||
|
|
)
|
||
|
|
|
||
|
|
def parse(self, data):
|
||
|
|
return {k: v for i in self.inputs for k, v in i.parse(data).items()}
|
||
|
|
|
||
|
|
|
||
|
|
class SettingsController(AuthorizationMixin, WebpageController):
|
||
|
|
def indexAction(self):
|
||
|
|
self.serve_template("settings.html", **self.template_variables())
|