Author: jmorliaguet
Date: Sun Dec  4 14:12:45 2005
New Revision: 1953

Modified:
   cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
   cpsskins/branches/jmo-perspectives/browser/editing/views.py
   cpsskins/branches/jmo-perspectives/elements/format.py
   cpsskins/branches/jmo-perspectives/elements/interfaces.py
Log:

- better support for settings



Modified: cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     Sun Dec 
 4 14:12:45 2005
@@ -34,7 +34,7 @@
           <a i18n:translate=""
              tal:attributes="
                class python: format['selected'] and 'itemselected' or 'item';
-               href string:./@@edit-menu.html?format=${format/name}"
+               href format/url"
              tal:content="format/title" />
         </li>
       </tal:block>

Modified: cpsskins/branches/jmo-perspectives/browser/editing/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/views.py (original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/views.py Sun Dec  4 
14:12:45 2005
@@ -28,11 +28,12 @@
 
 from cpsskins import configuration
 from cpsskins.elements.interfaces import IElement, IDisplayable, IFormattable
+from cpsskins.elements.interfaces import IType
 from cpsskins.browser.negociation.interfaces import INegociation
 from cpsskins.ontology import hasFormat
 from cpsskins.relations.interfaces import IRelationTool
 from cpsskins.relations.relations import DyadicRelation
-from cpsskins.setup.interfaces import IResourceManager, ISetting
+from cpsskins.setup.interfaces import IResourceManager, IResource, ISetting
 
 #######################################################################
 # Generic views
@@ -95,8 +96,9 @@
         request = self.request
 
         form = request.form
-        main_url = form.get('main_url')
         format_name = form.get('format')
+        main_url = form.get('main_url')
+        action = form.get('action', '@@edit.html')
 
         negociation = getMultiAdapter((context, request),
                                       INegociation, 'negociation')
@@ -108,19 +110,23 @@
 
         main = context
         formats_info = []
-        for f in formattable.getFormats():
+        for f in formattable.getFormats(resolve=False):
+            format = f
+            is_setting = ISetting.providedBy(f)
+            if is_setting:
+                f = IResource(f).getResource()
             name = f.formatname
             selected = name == format_name
             if selected:
-                main = f
+                main = format
+                action = is_setting and '@@edit-settings.html' or action
             formats_info.append({
+                'title': IType(f).getContentType().__name__,
+                'url': './@@edit-menu.html?format=%s' % name,
                 'selected': selected,
-                'name': f.formatname,
-                'title': f.formatname,
                 })
 
-        base_url = self.getAbsoluteURL(main) + '/'
-        main_url = main_url or base_url + form.get('action', '@@edit.html')
+        main_url = main_url or self.getAbsoluteURL(main) + '/' + action
 
         element_info = {
             'selected': not format_name,
@@ -129,11 +135,11 @@
         return {
             'negociation': negociation,
             'perspective': perspective,
-            'format_name': format_name,
             'display': display,
+            'format_name': format_name,
+            'element': element_info,
             'formats': formats_info,
             'main_url': main_url,
-            'element': element_info,
             }
 
 #######################################################################

Modified: cpsskins/branches/jmo-perspectives/elements/format.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/format.py       (original)
+++ cpsskins/branches/jmo-perspectives/elements/format.py       Sun Dec  4 
14:12:45 2005
@@ -108,14 +108,14 @@
         formats = getUtility(IFormatStorage, context=self.context)
         return formats.remove(format)
 
-    def getFormats(self, name=u''):
+    def getFormats(self, name=u'', resolve=True):
         context = self.context
         reltool = IRelationTool(context)
         format = queryUtility(configuration.IFormat, name)
         predicate = format and format.predicate or hasFormat
         formats = []
         for format in reltool.getSeconds(first=context, predicate=predicate):
-            if ISetting.providedBy(format):
+            if resolve and ISetting.providedBy(format):
                 format = IResource(format).getResource()
             formats.append(format)
         return formats

Modified: cpsskins/branches/jmo-perspectives/elements/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/interfaces.py   (original)
+++ cpsskins/branches/jmo-perspectives/elements/interfaces.py   Sun Dec  4 
14:12:45 2005
@@ -111,7 +111,7 @@
 
 class IFormattable(Interface):
 
-    def getFormats(name):
+    def getFormats(name, resolve):
         """ """
 
     def getFormatNames():
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to