From a34b01a6c4a6efaeb072fadd34b3207e95614dc8 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 20 Aug 2024 23:01:46 -0500 Subject: [PATCH] fix: cleanup logic for appinfo/configure so tailbone can inherit this view and extend --- src/wuttaweb/templates/appinfo/configure.mako | 36 +++--- src/wuttaweb/views/settings.py | 107 +++++++++--------- 2 files changed, 72 insertions(+), 71 deletions(-) diff --git a/src/wuttaweb/templates/appinfo/configure.mako b/src/wuttaweb/templates/appinfo/configure.mako index 5d1f7bb..d2de2cf 100644 --- a/src/wuttaweb/templates/appinfo/configure.mako +++ b/src/wuttaweb/templates/appinfo/configure.mako @@ -46,30 +46,30 @@

User/Auth

- +
Home Page auto-redirect to Login - - - - - + <${b}-tooltip position="${'right' if request.use_oruga else 'is-right'}"> + + + +
diff --git a/src/wuttaweb/views/settings.py b/src/wuttaweb/views/settings.py index f4d9551..fb67ae8 100644 --- a/src/wuttaweb/views/settings.py +++ b/src/wuttaweb/views/settings.py @@ -28,7 +28,6 @@ import json import os import sys import subprocess - from collections import OrderedDict from wuttjamaican.db.model import Setting @@ -67,6 +66,9 @@ class AppInfoView(MasterView): 'editable_project_location', ] + # TODO: for tailbone backward compat with get_liburl() etc. + weblib_config_prefix = None + def get_grid_data(self, columns=None, session=None): """ """ @@ -93,57 +95,9 @@ class AppInfoView(MasterView): g.sort_multiple = False - def configure_get_simple_settings(self): + def get_weblibs(self): """ """ - return [ - - # basics - {'name': f'{self.app.appname}.app_title'}, - {'name': f'{self.app.appname}.node_type'}, - {'name': f'{self.app.appname}.node_title'}, - {'name': f'{self.app.appname}.production', - 'type': bool}, - - # user/auth - {'name': 'wuttaweb.home_redirect_to_login', - 'type': bool, 'default': False}, - - # web libs - {'name': 'wuttaweb.libver.vue'}, - {'name': 'wuttaweb.liburl.vue'}, - {'name': 'wuttaweb.libver.vue_resource'}, - {'name': 'wuttaweb.liburl.vue_resource'}, - {'name': 'wuttaweb.libver.buefy'}, - {'name': 'wuttaweb.liburl.buefy'}, - {'name': 'wuttaweb.libver.buefy.css'}, - {'name': 'wuttaweb.liburl.buefy.css'}, - {'name': 'wuttaweb.libver.fontawesome'}, - {'name': 'wuttaweb.liburl.fontawesome'}, - {'name': 'wuttaweb.libver.bb_vue'}, - {'name': 'wuttaweb.liburl.bb_vue'}, - {'name': 'wuttaweb.libver.bb_oruga'}, - {'name': 'wuttaweb.liburl.bb_oruga'}, - {'name': 'wuttaweb.libver.bb_oruga_bulma'}, - {'name': 'wuttaweb.liburl.bb_oruga_bulma'}, - {'name': 'wuttaweb.libver.bb_oruga_bulma_css'}, - {'name': 'wuttaweb.liburl.bb_oruga_bulma_css'}, - {'name': 'wuttaweb.libver.bb_fontawesome_svg_core'}, - {'name': 'wuttaweb.liburl.bb_fontawesome_svg_core'}, - {'name': 'wuttaweb.libver.bb_free_solid_svg_icons'}, - {'name': 'wuttaweb.liburl.bb_free_solid_svg_icons'}, - {'name': 'wuttaweb.libver.bb_vue_fontawesome'}, - {'name': 'wuttaweb.liburl.bb_vue_fontawesome'}, - - ] - - def configure_get_context(self, **kwargs): - """ """ - - # normal context - context = super().configure_get_context(**kwargs) - - # we will add `weblibs` to context, based on config values - weblibs = OrderedDict([ + return OrderedDict([ ('vue', "(Vue2) Vue"), ('vue_resource', "(Vue2) vue-resource"), ('buefy', "(Vue2) Buefy"), @@ -158,6 +112,48 @@ class AppInfoView(MasterView): ('bb_vue_fontawesome', "(Vue3) @fortawesome/vue-fontawesome"), ]) + def configure_get_simple_settings(self): + """ """ + simple_settings = [ + + # basics + {'name': f'{self.app.appname}.app_title'}, + {'name': f'{self.app.appname}.node_type'}, + {'name': f'{self.app.appname}.node_title'}, + {'name': f'{self.app.appname}.production', + 'type': bool}, + + # user/auth + {'name': 'wuttaweb.home_redirect_to_login', + 'type': bool, 'default': False}, + + ] + + def getval(key): + return self.config.get(f'wuttaweb.{key}') + + weblibs = self.get_weblibs() + for key, title in weblibs.items(): + + simple_settings.append({ + 'name': f'wuttaweb.libver.{key}', + 'default': getval(f'libver.{key}'), + }) + simple_settings.append({ + 'name': f'wuttaweb.liburl.{key}', + 'default': getval(f'liburl.{key}'), + }) + + return simple_settings + + def configure_get_context(self, **kwargs): + """ """ + + # normal context + context = super().configure_get_context(**kwargs) + + # we will add `weblibs` to context, based on config values + weblibs = self.get_weblibs() for key in weblibs: title = weblibs[key] weblibs[key] = { @@ -167,13 +163,18 @@ class AppInfoView(MasterView): # nb. these values are exactly as configured, and are # used for editing the settings 'configured_version': get_libver(self.request, key, + prefix=self.weblib_config_prefix, configured_only=True), 'configured_url': get_liburl(self.request, key, + prefix=self.weblib_config_prefix, configured_only=True), # nb. these are for display only - 'default_version': get_libver(self.request, key, default_only=True), - 'live_url': get_liburl(self.request, key), + 'default_version': get_libver(self.request, key, + prefix=self.weblib_config_prefix, + default_only=True), + 'live_url': get_liburl(self.request, key, + prefix=self.weblib_config_prefix), } context['weblibs'] = list(weblibs.values())