fix: cleanup logic for appinfo/configure
so tailbone can inherit this view and extend
This commit is contained in:
parent
1b4aaacc10
commit
a34b01a6c4
|
@ -46,30 +46,30 @@
|
||||||
<h3 class="block is-size-3">User/Auth</h3>
|
<h3 class="block is-size-3">User/Auth</h3>
|
||||||
<div class="block" style="padding-left: 2rem; width: 50%;">
|
<div class="block" style="padding-left: 2rem; width: 50%;">
|
||||||
|
|
||||||
<b-field>
|
<div style="display: flex; align-items: center;">
|
||||||
<b-checkbox name="wuttaweb.home_redirect_to_login"
|
<b-checkbox name="wuttaweb.home_redirect_to_login"
|
||||||
v-model="simpleSettings['wuttaweb.home_redirect_to_login']"
|
v-model="simpleSettings['wuttaweb.home_redirect_to_login']"
|
||||||
native-value="true"
|
native-value="true"
|
||||||
@input="settingsNeedSaved = true">
|
@input="settingsNeedSaved = true">
|
||||||
Home Page auto-redirect to Login
|
Home Page auto-redirect to Login
|
||||||
<b-tooltip position="is-right">
|
|
||||||
<b-icon pack="fas" icon="info-circle" />
|
|
||||||
<template v-slot:content>
|
|
||||||
<p class="block">
|
|
||||||
If set, show the Login page instead of Home page for Anonymous users.
|
|
||||||
</p>
|
|
||||||
<p class="block has-text-weight-bold">
|
|
||||||
This only "enforces" Login for the Home page, not for
|
|
||||||
other pages. Anonymous users can see whatever the role
|
|
||||||
permissions authorize.
|
|
||||||
</p>
|
|
||||||
<p class="block">
|
|
||||||
If not set, Anonymous users will see the Home page without being redirected.
|
|
||||||
</p>
|
|
||||||
</template>
|
|
||||||
</b-tooltip>
|
|
||||||
</b-checkbox>
|
</b-checkbox>
|
||||||
</b-field>
|
<${b}-tooltip position="${'right' if request.use_oruga else 'is-right'}">
|
||||||
|
<b-icon pack="fas" icon="info-circle" />
|
||||||
|
<template #content>
|
||||||
|
<p class="block">
|
||||||
|
If set, show the Login page instead of Home page for Anonymous users.
|
||||||
|
</p>
|
||||||
|
<p class="block has-text-weight-bold">
|
||||||
|
This only "enforces" Login for the Home page, not for
|
||||||
|
other pages. Anonymous users can see whatever the role
|
||||||
|
permissions authorize.
|
||||||
|
</p>
|
||||||
|
<p class="block">
|
||||||
|
If not set, Anonymous users will see the Home page without being redirected.
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
</${b}-tooltip>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from wuttjamaican.db.model import Setting
|
from wuttjamaican.db.model import Setting
|
||||||
|
@ -67,6 +66,9 @@ class AppInfoView(MasterView):
|
||||||
'editable_project_location',
|
'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):
|
def get_grid_data(self, columns=None, session=None):
|
||||||
""" """
|
""" """
|
||||||
|
|
||||||
|
@ -93,57 +95,9 @@ class AppInfoView(MasterView):
|
||||||
|
|
||||||
g.sort_multiple = False
|
g.sort_multiple = False
|
||||||
|
|
||||||
def configure_get_simple_settings(self):
|
def get_weblibs(self):
|
||||||
""" """
|
""" """
|
||||||
return [
|
return OrderedDict([
|
||||||
|
|
||||||
# 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([
|
|
||||||
('vue', "(Vue2) Vue"),
|
('vue', "(Vue2) Vue"),
|
||||||
('vue_resource', "(Vue2) vue-resource"),
|
('vue_resource', "(Vue2) vue-resource"),
|
||||||
('buefy', "(Vue2) Buefy"),
|
('buefy', "(Vue2) Buefy"),
|
||||||
|
@ -158,6 +112,48 @@ class AppInfoView(MasterView):
|
||||||
('bb_vue_fontawesome', "(Vue3) @fortawesome/vue-fontawesome"),
|
('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:
|
for key in weblibs:
|
||||||
title = weblibs[key]
|
title = weblibs[key]
|
||||||
weblibs[key] = {
|
weblibs[key] = {
|
||||||
|
@ -167,13 +163,18 @@ class AppInfoView(MasterView):
|
||||||
# nb. these values are exactly as configured, and are
|
# nb. these values are exactly as configured, and are
|
||||||
# used for editing the settings
|
# used for editing the settings
|
||||||
'configured_version': get_libver(self.request, key,
|
'configured_version': get_libver(self.request, key,
|
||||||
|
prefix=self.weblib_config_prefix,
|
||||||
configured_only=True),
|
configured_only=True),
|
||||||
'configured_url': get_liburl(self.request, key,
|
'configured_url': get_liburl(self.request, key,
|
||||||
|
prefix=self.weblib_config_prefix,
|
||||||
configured_only=True),
|
configured_only=True),
|
||||||
|
|
||||||
# nb. these are for display only
|
# nb. these are for display only
|
||||||
'default_version': get_libver(self.request, key, default_only=True),
|
'default_version': get_libver(self.request, key,
|
||||||
'live_url': get_liburl(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())
|
context['weblibs'] = list(weblibs.values())
|
||||||
|
|
Loading…
Reference in a new issue