split settings controller module (preparation to split general settings)
This commit is contained in:
33
owrx/controllers/settings/__init__.py
Normal file
33
owrx/controllers/settings/__init__.py
Normal file
@@ -0,0 +1,33 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user