Added attributes to configuration
authorThierry Florac <thierry.florac@onf.fr>
Tue, 11 Oct 2016 16:10:54 +0200
changeset 157 c716d9f34203
parent 156 b8b688fc964e
child 158 c5c43a017927
Added attributes to configuration
src/pyams_skin/configuration.py
src/pyams_skin/interfaces/configuration.py
--- a/src/pyams_skin/configuration.py	Mon Oct 10 15:27:10 2016 +0200
+++ b/src/pyams_skin/configuration.py	Tue Oct 11 16:10:54 2016 +0200
@@ -49,7 +49,7 @@
 #
 
 @adapter_config(context=(IStaticConfigurationManager, Interface, Interface), provides=IStaticConfiguration)
-class StaticConfiguration(object):
+class StaticConfiguration(ContextRequestViewAdapter):
     """Default static configuration"""
 
     application_package = 'pyams_skin'
@@ -57,6 +57,7 @@
 
     version_location = 'menus'
 
+    include_header = True
     include_top_links = True
     include_site_search = True
     site_search_placeholder = _("Search...")
@@ -74,11 +75,6 @@
     include_reload_button = True
     body_css_class = 'fixed-header fixed-ribbon fixed-navigation'
 
-    def __init__(self, context, request, view):
-        self.context = context
-        self.request = request
-        self.view = view
-
     @property
     def version(self):
         return pkg_resources.get_distribution(self.application_package).version
@@ -106,11 +102,18 @@
     """Manageable configuration"""
 
     title = FieldProperty(IConfiguration['title'])
+    short_title = FieldProperty(IConfiguration['short_title'])
     description = FieldProperty(IConfiguration['description'])
     author = FieldProperty(IConfiguration['author'])
     icon = FileProperty(IConfiguration['icon'])
     logo = FileProperty(IConfiguration['logo'])
 
+    @staticmethod
+    def get_title_prefix(request):
+        adapter = get_current_registry().queryMultiAdapter((request.context, request), IContextTitlePrefix)
+        if adapter is not None:
+            return adapter.prefix
+
 
 @adapter_config(context=IConfigurationManager, provides=IConfiguration)
 def ConfigurationFactory(context):
--- a/src/pyams_skin/interfaces/configuration.py	Mon Oct 10 15:27:10 2016 +0200
+++ b/src/pyams_skin/interfaces/configuration.py	Tue Oct 11 16:10:54 2016 +0200
@@ -47,6 +47,10 @@
                               values=(u'menus', u'shortcuts'),
                               default=u'menus')
 
+    include_header = Bool(title="Include header?",
+                          default=True,
+                          required=True)
+
     include_top_links = Bool(title="Include top links?",
                              default=True,
                              required=True)
@@ -125,6 +129,13 @@
                      description=_("Application title displayed in title bar"),
                      required=False)
 
+    short_title = TextLine(title=_("Short title"),
+                           description=_("Application short title visible as title prefix"),
+                           required=False)
+
+    def get_title_prefix(self, request):
+        """Get title prefix based on current navigation context"""
+
     description = TextLine(title=_("Description"),
                            description=_("Main application description"),
                            required=False)