rename template variable

This commit is contained in:
Jakob Ketterl 2021-02-18 23:05:43 +01:00
parent c5585e290a
commit d65743f2ea
3 changed files with 16 additions and 18 deletions

View File

@ -12,9 +12,9 @@
<body>
${header}
<div class="container">
<div class="col-12">
<h1>${title}</h1>
<div class="row">
<h1 class="col-12">${title}s</h1>
</div>
${sections}
${content}
</div>
</body>

View File

@ -67,7 +67,7 @@ class SettingsFormController(AuthorizationMixin, WebpageController, metaclass=AB
def template_variables(self):
variables = super().template_variables()
variables["sections"] = self.render_sections()
variables["content"] = self.render_sections()
variables["title"] = self.getTitle()
return variables

View File

@ -1,8 +1,6 @@
from owrx.controllers.admin import AuthorizationMixin
from owrx.controllers.template import WebpageController
from owrx.config import Config
from urllib.parse import quote
import json
class SdrSettingsController(AuthorizationMixin, WebpageController):
@ -13,20 +11,12 @@ class SdrSettingsController(AuthorizationMixin, WebpageController):
def template_variables(self):
variables = super().template_variables()
variables["sections"] = self.render_devices()
variables["content"] = self.render_devices()
variables["title"] = "SDR device settings"
return variables
def render_devices(self):
return """
<div class="col-12">
{devices}
</div>
""".format(
devices="".join(self.render_device(key, value) for key, value in Config.get()["sdrs"].items())
)
def render_device(self, device_id, config):
def render_device(device_id, config):
return """
<div class="card device bg-dark text-white">
<div class="card-header">
@ -40,5 +30,13 @@ class SdrSettingsController(AuthorizationMixin, WebpageController):
device_name=config["name"]
)
return """
<div class="col-12">
{devices}
</div>
""".format(
devices="".join(render_device(key, value) for key, value in Config.get()["sdrs"].items())
)
def indexAction(self):
self.serve_template("settings/general.html", **self.template_variables())