Author: jmorliaguet
Date: Tue Jun  6 18:22:53 2006
New Revision: 3337

Modified:
   
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt
   cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py

Log:

- fixes / simplifications



Modified: 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt  
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/element_editor.pt  
    Tue Jun  6 18:22:53 2006
@@ -8,11 +8,10 @@
   display_id display/identifier;
   preset nocall:info/preset;
   edited nocall:info/edited;
-  edited_type edited/type:name;
   format request/form/format|nothing;
   tab request/form/tab|nothing;
   display_name display/type:name;
-  preset_info edited/@@getPresetsInfo">
+  presets info/presets">
   <a class="back"
      
href="javascript:CPSSkins.getControllerById('main-editor-perspectives').goBack()">&lt;
 back to the editor</a>
   <h1 class="title" tal:define="title element/title">
@@ -44,12 +43,12 @@
 
     <form style="float:right"
           tal:define="preset_uri info/preset_uri"
-          tal:condition="python: format and edited_type in preset_info"
+          tal:condition="presets"
           tal:attributes="action string:${display/@@absolute_url}/@@usePreset">
       Use preset:
       <select class="presetSelector" name="uri">
         <option value="_">(no preset)</option>
-        <option tal:repeat="preset preset_info/?edited_type"
+        <option tal:repeat="preset presets"
                 tal:attributes="value preset/uri;
                                 class python: preset['readonly'] and 
'readonly' or nothing;
                                 selected python: preset_uri == preset['uri']">

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py       
Tue Jun  6 18:22:53 2006
@@ -27,13 +27,12 @@
 from cpsskins.browser.rendering.interfaces import IViewer
 from cpsskins.elements.interfaces import IDisplay, IFormat
 from cpsskins.elements.interfaces import IDisplayable, IFormattable
-from cpsskins.relations import DyadicRelation
 from cpsskins.setup.interfaces import IType, IIdentifiable
 from cpsskins.setup.interfaces import IResourceManager, IResource, IPreset
 from cpsskins.setup.io import importSite, exportSite
 from cpsskins.setup.snapshot import Snapshot
 from cpsskins.storage.interfaces import IStorage
-from cpsskins.utils import getThemeManager, getRelationStorage
+from cpsskins.utils import getThemeManager
 
 class Form(object):
     """An edit form for elements.
@@ -70,6 +69,7 @@
         request = self.request
 
         tmutil = getThemeManager(context)
+        resources = getUtility(IResourceManager)
 
         form = request.form
         element_id = form.get('id')
@@ -104,7 +104,6 @@
             format = f
             is_preset = IPreset.providedBy(f)
             if is_preset:
-                if f.isGlobal():
                 f = IResource(f).getResource()
 
             id = f.identifier or 0
@@ -124,6 +123,14 @@
         viewer = getMultiAdapter((context, request), IViewer)
         preview = viewer()
 
+        edited_type = IType(edited).getResourceType()
+        presets = [{
+            'name': p.name,
+            'uri': IIdentifiable(p).getURI(),
+            'preset': p,
+            'readonly': p.isGlobal(),
+            } for p in resources.list(type=edited_type, context=context)]
+
         uri = IIdentifiable(edited).getURI()
         return {
             'negotiation': negotiation,
@@ -134,6 +141,7 @@
             'edited': edited,
             'uri': uri,
             'preset': preset,
+            'presets': presets,
             'preset_uri': preset_uri,
             'preview': preview,
             }
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to