Moved "static" configuration to persistent configuration in pyams_zmi package
authorThierry Florac <tflorac@ulthar.net>
Sun, 11 Mar 2018 11:09:25 +0100
changeset 282 01df243eb6d1
parent 281 4d5aef9ecf5f
child 283 c69daf695ed9
Moved "static" configuration to persistent configuration in pyams_zmi package
src/pyams_skin/configuration.py
src/pyams_skin/interfaces/configuration.py
src/pyams_skin/interfaces/templates/fullpage-layout.pt
src/pyams_skin/interfaces/templates/fullpage-modal-layout.pt
src/pyams_skin/viewlet/search/site-search.pt
--- a/src/pyams_skin/configuration.py	Sat Mar 10 17:10:43 2018 +0100
+++ b/src/pyams_skin/configuration.py	Sun Mar 11 11:09:25 2018 +0100
@@ -14,14 +14,12 @@
 
 
 # import standard library
-import pkg_resources
 
 # import interfaces
 from pyams_skin.interfaces import IContextTitlePrefix
-from pyams_skin.interfaces.configuration import IStaticConfiguration, IConfiguration, SKIN_CONFIGURATION_KEY, \
+from pyams_skin.interfaces.configuration import IConfiguration, SKIN_CONFIGURATION_KEY, \
     IBackOfficeConfiguration, SKIN_BACK_CONFIGURATION_KEY
-from pyams_utils.interfaces.site import IStaticConfigurationManager, IConfigurationManager, IConfigurationFactory, \
-    IBackOfficeConfigurationFactory
+from pyams_utils.interfaces.site import IConfigurationManager, IConfigurationFactory, IBackOfficeConfigurationFactory
 from pyams_utils.interfaces.tales import ITALESExtension
 from zope.annotation.interfaces import IAnnotations
 from zope.traversing.interfaces import ITraversable
@@ -41,63 +39,6 @@
 from zope.location.location import locate
 from zope.schema.fieldproperty import FieldProperty
 
-from pyams_skin import _
-
-
-#
-# Static configuration
-#
-
-@adapter_config(context=(IStaticConfigurationManager, Interface, Interface), provides=IStaticConfiguration)
-class StaticConfiguration(ContextRequestViewAdapter):
-    """Default static configuration"""
-
-    application_package = 'pyams_skin'
-    application_name = 'PyAMS'
-    inner_package = None
-    inner_package_name = None
-
-    version_location = 'menus'
-
-    include_header = True
-    include_top_links = True
-    include_site_search = True
-    site_search_placeholder = _("Search...")
-    site_search_handler = '#search.html'
-    include_mobile_search = True
-    mobile_search_placeholder = _("Search...")
-    mobile_search_handler = '#search.html'
-    include_user_activity = True
-    include_user_shortcuts = True
-    include_logout_button = True
-    include_minify_button = True
-    include_flags = False
-    include_menus = True
-    accordion_menus = True
-    include_ribbon = True
-    include_reload_button = True
-    body_css_class = 'fixed-header fixed-ribbon fixed-navigation'
-
-    @property
-    def version(self):
-        result = pkg_resources.get_distribution(self.application_package).version
-        if self.inner_package:
-            result += ' (%s v%s)' % (self.inner_package_name,
-                                     pkg_resources.get_distribution(self.inner_package).version)
-        return result
-
-
-@adapter_config(name='static_configuration', context=(Interface, Interface, Interface), provides=ITALESExtension)
-class StaticConfigurationTalesExtension(ContextRequestViewAdapter):
-    """extension:static_configuration TALES expression"""
-
-    def render(self, context=None):
-        if context is None:
-            context = self.context
-        target = get_parent(context, IStaticConfigurationManager)
-        registry = self.request.registry
-        return registry.queryMultiAdapter((target, self.request, self.view), IStaticConfiguration)
-
 
 #
 # Dynamic front-office configuration
--- a/src/pyams_skin/interfaces/configuration.py	Sat Mar 10 17:10:43 2018 +0100
+++ b/src/pyams_skin/interfaces/configuration.py	Sun Mar 11 11:09:25 2018 +0100
@@ -20,113 +20,11 @@
 
 # import packages
 from pyams_file.schema import ImageField
-from zope.interface import Interface, Attribute
-from zope.schema import TextLine, Text, Choice, Bool
+from zope.schema import TextLine, Text, Bool
 
 from pyams_skin import _
 
 
-class IStaticConfiguration(Interface):
-    """Static configuration interface
-
-    These configuration options are used by default presentation layout
-    """
-
-    application_package = TextLine(title="Main application package",
-                                   description="This package is used to get current application version",
-                                   required=False)
-
-    application_name = TextLine(title="Main application name",
-                                description="This name is used to display application version",
-                                required=False)
-
-    inner_package = TextLine(title=_("Inner package"),
-                             description=_("This is another important package displayed in application version"),
-                             required=False)
-
-    inner_package_name = TextLine(title=_("Inner package name"),
-                                  description=_("Package name used to display application version"),
-                                  required=False)
-
-    version = Attribute("Application version")
-
-    version_location = Choice(title="Version label location",
-                              required=False,
-                              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)
-
-    include_site_search = Bool(title="Include site search?",
-                               default=True,
-                               required=False)
-
-    site_search_placeholder = TextLine(title="Site search placeholder",
-                                       required=False,
-                                       default=_("Search..."))
-
-    site_search_handler = TextLine(title="Site search handler",
-                                   required=False,
-                                   default="#search.html")
-
-    include_mobile_search = Bool(title="Include mobile search?",
-                                 default=True,
-                                 required=False)
-
-    mobile_search_placeholder = TextLine(title="Mobile search placeholder",
-                                         required=False,
-                                         default=_("Search..."))
-
-    mobile_search_handler = TextLine(title="Mobile search handler",
-                                     required=False,
-                                     default='#search.html')
-
-    include_user_activity = Bool(title="Include user dropdown window?",
-                                 default=True,
-                                 required=True)
-
-    include_user_shortcuts = Bool(title="Include user shortcuts?",
-                                  default=True,
-                                  required=True)
-
-    include_logout_button = Bool(title="Include logout button?",
-                                 default=True,
-                                 required=True)
-
-    include_minify_button = Bool(title="Include minify button?",
-                                 default=True,
-                                 required=True)
-
-    include_flags = Bool(title="Include flags menu?",
-                         default=True,
-                         required=False)
-
-    include_menus = Bool(title="Include main menus?",
-                         default=True,
-                         required=True)
-
-    accordion_menus = Bool(title="Display menus as accordion?",
-                           default=True,
-                           required=True)
-
-    include_ribbon = Bool(title="Include ribbon?",
-                          default=True,
-                          required=True)
-
-    include_reload_button = Bool(title="Include reload button?",
-                                 default=True,
-                                 required=True)
-
-    body_css_class = TextLine(title="Body HTML tag CSS class",
-                              required=False)
-
-
 SKIN_CONFIGURATION_KEY = 'pyams_skin.configuration'
 
 
--- a/src/pyams_skin/interfaces/templates/fullpage-layout.pt	Sat Mar 10 17:10:43 2018 +0100
+++ b/src/pyams_skin/interfaces/templates/fullpage-layout.pt	Sun Mar 11 11:09:25 2018 +0100
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en" i18n:domain="pyams_skin"
 	  tal:define="config extension:back_configuration;
-				  static extension:static_configuration;"
+				  zmi extension:zmi_configuration;"
 	  tal:attributes="lang request.locale_name">
 <head>
 	<tal:var replace="structure extension:metas" />
@@ -18,7 +18,7 @@
 	<tal:var replace="extension:resources" />
 
 </head>
-<body tal:attributes="class static.body_css_class">
+<body tal:attributes="class zmi.body_css_class">
 
 	<!-- Content -->
 	<div id="content" style="opacity: 1;">
--- a/src/pyams_skin/interfaces/templates/fullpage-modal-layout.pt	Sat Mar 10 17:10:43 2018 +0100
+++ b/src/pyams_skin/interfaces/templates/fullpage-modal-layout.pt	Sun Mar 11 11:09:25 2018 +0100
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html lang="en" i18n:domain="pyams_skin"
 	  tal:define="config extension:back_configuration;
-				  static extension:static_configuration;"
+				  zmi extension:zmi_configuration;"
 	  tal:attributes="lang request.locale_name">
 <head>
 	<tal:var replace="structure extension:metas" />
@@ -18,7 +18,7 @@
 	<tal:var replace="extension:resources" />
 
 </head>
-<body tal:attributes="class static.body_css_class">
+<body tal:attributes="class zmi.body_css_class">
 
 	<!-- Content -->
 	<div id="content" style="opacity: 1;">
--- a/src/pyams_skin/viewlet/search/site-search.pt	Sat Mar 10 17:10:43 2018 +0100
+++ b/src/pyams_skin/viewlet/search/site-search.pt	Sun Mar 11 11:09:25 2018 +0100
@@ -1,8 +1,8 @@
 <form method="post" action="#search.html" class="header-search pull-right" data-async
-	  tal:define="static extension:static_configuration"
-	  tal:attributes="action static.site_search_handler">
+	  tal:define="zmi extension:zmi_configuration"
+	  tal:attributes="action zmi.site_search_handler">
 	<input type="text" placeholder="Find reports and more" id="search-field" name="search-field"
-		   tal:attributes="placeholder static.site_search_placeholder">
+		   tal:attributes="placeholder i18n:zmi.site_search_placeholder">
 	<button type="submit">
 		<i class="fa fa-search"></i>
 	</button>