From e1ff4578e977dfca4dcc6d4213f1d2374c56d578 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 16 Apr 2019 15:44:02 -0500 Subject: [PATCH] Improve logic used to determine if current theme supports Buefy let settings define this per theme, but have sane defaults also --- tailbone/views/master.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tailbone/views/master.py b/tailbone/views/master.py index acda43d6..6fe4d198 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -252,6 +252,22 @@ class MasterView(View): return labels def get_use_buefy(self): + """ + Returns a flag indicating whether or not the current theme supports + (and therefore should use) the Buefy JS library. + """ + # first check theme-specific setting, if one has been defined + theme = self.request.registry.settings['tailbone.theme'] + buefy = self.rattail_config.getbool('tailbone', 'themes.{}.use_buefy'.format(theme)) + if buefy is not None: + return buefy + + # TODO: should not hard-code this surely, but works for now... + if theme == 'falafel': + return True + + # TODO: probably should not use this fallback? it was the first setting + # i tested with, but is poorly named to say the least return self.rattail_config.getbool('tailbone', 'grids.use_buefy', default=False) ##############################