Rename setting for custom user css (remove "buefy")

but have to keep support for older setting name for now
This commit is contained in:
Lance Edgar 2024-04-19 21:18:57 -05:00
parent 49da9776e7
commit 8781e34c98
3 changed files with 21 additions and 6 deletions

View file

@ -27,6 +27,7 @@ Event Subscribers
import six import six
import json import json
import datetime import datetime
import warnings
import rattail import rattail
@ -181,8 +182,13 @@ def before_render(event):
# maybe set custom stylesheet # maybe set custom stylesheet
css = None css = None
if request.user: if request.user:
css = request.rattail_config.get('tailbone.{}'.format(request.user.uuid), css = rattail_config.get(f'tailbone.{request.user.uuid}', 'user_css')
'buefy_css') if not css:
css = rattail_config.get(f'tailbone.{request.user.uuid}', 'buefy_css')
if css:
warnings.warn(f"setting 'tailbone.{request.user.uuid}.buefy_css' should be"
f"changed to 'tailbone.{request.user.uuid}.user_css'",
DeprecationWarning)
renderer_globals['user_css'] = css renderer_globals['user_css'] = css
# add global search data for quick access # add global search data for quick access

View file

@ -27,8 +27,8 @@
<div class="block" style="padding-left: 2rem;"> <div class="block" style="padding-left: 2rem;">
<b-field label="Theme Style"> <b-field label="Theme Style">
<b-select name="tailbone.${user.uuid}.buefy_css" <b-select name="tailbone.${user.uuid}.user_css"
v-model="simpleSettings['tailbone.${user.uuid}.buefy_css']" v-model="simpleSettings['tailbone.${user.uuid}.user_css']"
@input="settingsNeedSaved = true"> @input="settingsNeedSaved = true">
<option v-for="option in themeStyleOptions" <option v-for="option in themeStyleOptions"
:key="option.value" :key="option.value"

View file

@ -601,11 +601,18 @@ class UserView(PrincipalMasterView):
The only difference here is that we are given a user account, The only difference here is that we are given a user account,
so the settings involved should only pertain to that user. so the settings involved should only pertain to that user.
""" """
# TODO: can stop pre-fetching this value only once we are
# confident all settings have been updated in the wild
user_css = self.rattail_config.get(f'tailbone.{user.uuid}', 'user_css')
if not user_css:
user_css = self.rattail_config.get(f'tailbone.{user.uuid}', 'buefy_css')
return [ return [
# display # display
{'section': 'tailbone.{}'.format(user.uuid), {'section': f'tailbone.{user.uuid}',
'option': 'buefy_css'}, 'option': 'user_css',
'value': user_css},
] ]
def preferences_gather_settings(self, data, user): def preferences_gather_settings(self, data, user):
@ -614,9 +621,11 @@ class UserView(PrincipalMasterView):
data, simple_settings=simple_settings, input_file_templates=False) data, simple_settings=simple_settings, input_file_templates=False)
def preferences_remove_settings(self, user): def preferences_remove_settings(self, user):
app = self.get_rattail_app()
simple_settings = self.preferences_get_simple_settings(user) simple_settings = self.preferences_get_simple_settings(user)
self.configure_remove_settings(simple_settings=simple_settings, self.configure_remove_settings(simple_settings=simple_settings,
input_file_templates=False) input_file_templates=False)
app.delete_setting(self.Session(), f'tailbone.{user.uuid}.buefy_css')
@classmethod @classmethod
def defaults(cls, config): def defaults(cls, config):