diff --git a/tailbone/templates/poser/views/configure.mako b/tailbone/templates/poser/views/configure.mako
index 448c56f0..f4d75779 100644
--- a/tailbone/templates/poser/views/configure.mako
+++ b/tailbone/templates/poser/views/configure.mako
@@ -7,21 +7,14 @@
NB. Any changes made here will require an app restart!
-
Tailbone Views
-
-
People
- % for key, label in view_settings['people']:
- ${self.simple_flag(key, label)}
- % endfor
-
-
Products
- % for key, label in view_settings['products']:
- ${self.simple_flag(key, label)}
- % endfor
-
-
Other
- % for key, label in view_settings['other']:
- ${self.simple_flag(key, label)}
+ % for topkey, topgroup in sorted(view_settings.items(), key=lambda itm: 'aaaa' if itm[0] == 'rattail' else itm[0]):
+
Views for: ${topkey}
+ % for group_key, group in six.iteritems(topgroup):
+
${group_key.capitalize()}
+ % for key, label in group:
+ ${self.simple_flag(key, label)}
+ % endfor
+ % endfor
% endfor
%def>
@@ -32,7 +25,9 @@
v-model="simpleSettings['tailbone.includes.${key}']"
@input="settingsNeedSaved = true">
-
+ % for option in view_options[key]:
+
+ % endfor
%def>
diff --git a/tailbone/views/poser/views.py b/tailbone/views/poser/views.py
index 66a0b0db..a5fc9a4a 100644
--- a/tailbone/views/poser/views.py
+++ b/tailbone/views/poser/views.py
@@ -31,6 +31,7 @@ import six
import colander
from .master import PoserMasterView
+from tailbone.providers import get_all_providers
class PoserViewView(PoserMasterView):
@@ -94,7 +95,7 @@ class PoserViewView(PoserMasterView):
# TODO: this probably should be more dynamic? definitely need
# to let integration packages register some more options...
- return {
+ everything = {'rattail': {
'people': {
@@ -181,16 +182,59 @@ class PoserViewView(PoserMasterView):
'label': "Taxes",
},
},
- }
+ }}
+
+ for key, views in six.iteritems(everything['rattail']):
+ for vkey, view in six.iteritems(views):
+ view['options'] = [vkey]
+
+ providers = get_all_providers(self.rattail_config)
+ for provider in six.itervalues(providers):
+
+ # loop thru provider top-level groups
+ for topkey, groups in six.iteritems(provider.get_provided_views()):
+
+ # get or create top group
+ topgroup = everything.setdefault(topkey, {})
+
+ # loop thru provider view groups
+ for key, views in six.iteritems(groups):
+
+ # add group to top group, if it's new
+ if key not in topgroup:
+ topgroup[key] = views
+
+ # also must init the options for group
+ for vkey, view in six.iteritems(views):
+ view['options'] = [vkey]
+
+ else: # otherwise must "update" existing group
+
+ # get ref to existing ("standard") group
+ stdgroup = topgroup[key]
+
+ # loop thru views within provider group
+ for vkey, view in six.iteritems(views):
+
+ # add view to group if it's new
+ if vkey not in stdgroup:
+ view['options'] = [vkey]
+ stdgroup[vkey] = view
+
+ else: # otherwise "update" existing view
+ stdgroup[vkey]['options'].append(view['spec'])
+
+ return everything
def configure_get_simple_settings(self):
settings = []
view_settings = self.collect_available_view_settings()
- for view_section, section_settings in six.iteritems(view_settings):
- for key in section_settings:
- settings.append({'section': 'tailbone.includes',
- 'option': key})
+ for topgroup in six.itervalues(view_settings):
+ for view_section, section_settings in six.iteritems(topgroup):
+ for key in section_settings:
+ settings.append({'section': 'tailbone.includes',
+ 'option': key})
return settings
@@ -202,14 +246,23 @@ class PoserViewView(PoserMasterView):
simple_settings=simple_settings,
input_file_templates=input_file_templates)
- # add available settings as sorted (key, label) options
+ # first add available options
view_settings = self.collect_available_view_settings()
- for key in list(view_settings):
- settings = view_settings[key]
- settings = [(key, setting['label'])
- for key, setting in six.iteritems(settings)]
- settings.sort(key=lambda itm: itm[1])
- view_settings[key] = settings
+ view_options = {}
+ for topgroup in six.itervalues(view_settings):
+ for key, views in six.iteritems(topgroup):
+ for vkey, view in six.iteritems(views):
+ view_options[vkey] = view['options']
+ context['view_options'] = view_options
+
+ # then add all available settings as sorted (key, label) options
+ for topkey, topgroup in six.iteritems(view_settings):
+ for key in list(topgroup):
+ settings = topgroup[key]
+ settings = [(key, setting['label'])
+ for key, setting in six.iteritems(settings)]
+ settings.sort(key=lambda itm: itm[1])
+ topgroup[key] = settings
context['view_settings'] = view_settings
return context