From ba3242205916e730b25c46e16f14247ccb6d9b2e Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 25 Apr 2024 23:56:21 -0500 Subject: [PATCH] Fix bug when saving user preferences theme it was being saved even when it should have been empty value --- tailbone/views/users.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tailbone/views/users.py b/tailbone/views/users.py index fb81060a..e4182da9 100644 --- a/tailbone/views/users.py +++ b/tailbone/views/users.py @@ -612,14 +612,25 @@ class UserView(PrincipalMasterView): # display {'section': f'tailbone.{user.uuid}', 'option': 'user_css', - 'value': user_css}, + 'value': user_css, + 'save_if_empty': False}, ] def preferences_gather_settings(self, data, user): simple_settings = self.preferences_get_simple_settings(user) - return self.configure_gather_settings( + settings = self.configure_gather_settings( data, simple_settings=simple_settings, input_file_templates=False) + # TODO: ugh why does user_css come back as 'default' instead of None? + final_settings = [] + for setting in settings: + if setting['name'].endswith('.user_css'): + if setting['value'] == 'default': + continue + final_settings.append(setting) + + return final_settings + def preferences_remove_settings(self, user): app = self.get_rattail_app() simple_settings = self.preferences_get_simple_settings(user)