Author: jmorliaguet
Date: Wed May 31 20:13:30 2006
New Revision: 3283

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

Log:

- implemented the 'stop using a preset' function



Modified: cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/definitions.py       Wed May 
31 20:13:30 2006
@@ -588,7 +588,7 @@
             'feedback': {
                 'opacity': 0.93,
                 'clone': True,
-                'border': '#000',
+                'border': '#666',
             },
         },
         'shifting': {

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  
    Wed May 31 20:13:30 2006
@@ -12,55 +12,43 @@
   format request/form/format|nothing;
   tab request/form/tab|nothing;
   preset_info edited/@@getPresetsInfo">
-
   <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">
     <tal:block condition="not:title" i18n:translate=""
                content="info/element/name" />
     <tal:block condition="title" content="title" />
   </h1>
-
   <p class="description" tal:content="description"
-   tal:define="description element/description|string:No description" />
-
+     tal:define="description element/description|string:No description" />
   <ul class="tabs">
     <li>
       <a i18n:translate="" tal:content="info/element/name" tal:attributes="
          href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: '$id', mode: 'edit'}})" /></li>
-
     <li>
       <a i18n:translate="" tal:content="display/type:name" tal:attributes="
          href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: $id, tab: '${display/type:name}'}})" /></li>
-
     <li tal:repeat="format info/formats">
       <a i18n:translate="" tal:attributes="
          href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({script: 
'/++skin++cpsskins/++resource++style_editor.js', form: {id: $id, display: 
$display_id, format: ${format/id}, uri: '${format/uri}', tab: 
'${format/name}'}})"
        tal:content="format/name" /></li>
-
     <li>
       <a i18n:translate="" tal:attributes="
          href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: '$id', mode: 'preview'}})">Preview</a></li>
   </ul>
-
   <div class="form">
     <ul class="inlineTabs" style="float:right; font-style: normal"
         tal:condition="python: tab and not preset and mode != 
'manage-presets'">
       <li>
          <a tal:attributes="href 
string:javascript:CPSSkins.getModelById('element-editor').updateData({form: 
{id: $id, tab: '${edited_type}', mode: 'manage-presets'} })">manage 
presets</a></li>
     </ul>
-
     <tal:block condition="python: mode == 'edit' and preset is None"
                content="structure edited/@@edit.html" />
-
     <fieldset class="panel" tal:condition="python: mode == 'preview'">
       <legend class="panelTitle">Preview</legend>
       <tal:block content="structure info/preview" />
     </fieldset>
-
     <div tal:condition="python: mode == 'manage-presets' or preset">
-
       <table style="width: 100%" cellpadding="0" cellspacing="0">
         <tr>
           <td style="vertical-align: top; width: 50%">
@@ -68,16 +56,23 @@
               <legend class="panelTitle">Unselect the preset</legend>
               <p>The '<cite tal:content="preset/name" />' preset is currently
                  being used.</p>
-              <form enctype="multipart/form-data" method="post"
-                    tal:attributes="action 
string:${display/@@absolute_url}/@@stopUsingPreset">
-                <p>
-                  <input type="submit" name="UPDATE_SUBMIT"
-                         value="Unselect" />
-                </p>
+              <form tal:attributes="action 
string:${display/@@absolute_url}/@@stopUsingPreset">
+                <input type="hidden" name="uri" tal:attributes="value 
info/preset_uri" />
+                <input type="submit" name="UPDATE_SUBMIT"
+                       value="Stop using the preset" />
               </form>
             </fieldset>
+            <fieldset class="panel"
+                      tal:condition="python: edited_type in preset_info">
+              <legend class="panelTitle">Use a preset</legend>
+              <ul class="inlineTabs">
+                <li tal:repeat="preset preset_info/?edited_type">
+                  <a href="" tal:content="preset/name"
+                   tal:attributes="href 
string:${display/@@absolute_url}/@@usePreset?uri=${preset/uri}" /></li>
+              </ul>
+            </fieldset>
             <fieldset class="panel" tal:condition="not:preset">
-              <legend class="panelTitle">Create a preset</legend>
+              <legend class="panelTitle">Create a new preset</legend>
               <form enctype="multipart/form-data" method="post"
                     tal:attributes="action 
string:${edited/@@absolute_url}/@@createPreset">
                 <p>
@@ -89,15 +84,6 @@
                 </p>
               </form>
             </fieldset>
-            <fieldset class="panel"
-                      tal:condition="python: edited_type in preset_info">
-              <legend class="panelTitle">Select a preset</legend>
-              <ul class="inlineTabs">
-                <li tal:repeat="preset preset_info/?edited_type">
-                  <a href="" tal:content="preset/name"
-                   tal:attributes="href 
string:${display/@@absolute_url}/@@usePreset?uri=${preset/uri}" /></li>
-              </ul>
-            </fieldset>
           </td>
           <td style="vertical-align: top; width: 50%">
             <fieldset class="panel">
@@ -107,16 +93,15 @@
                           content="string:'${preset/name}'" />
               </legend>
               <ul style="float:right" class="inlineTabs" 
tal:condition="preset">
+                <!--
                 <li><a tal:attributes="href 
string:${preset/@@absolute_url}/@@edit.html">modify settings</a></li>
+                -->
               </ul>
               <tal:block content="structure info/preview" />
             </fieldset>
           </td>
         </tr>
       </table>
-
     </div>
-
   </div>
-
 </tal:block>

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       
Wed May 31 20:13:30 2006
@@ -95,6 +95,7 @@
         # Formats
         formats = []
         preset = None
+        preset_uri = u''
 
         for f in formattable.getFormats(resolve=False):
             uri = IIdentifiable(f).getURI()
@@ -110,6 +111,7 @@
                 edited = f
                 if is_preset:
                     preset = format
+                    preset_uri = uri
 
             formats.append({'name': format_name, 'id': f.identifier or 0,
                             'uri': uri, 'is_preset': is_preset})
@@ -127,6 +129,7 @@
             'edited': edited,
             'uri': uri,
             'preset': preset,
+            'preset_uri': preset_uri,
             'preview': preview,
             }
 

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Wed May 
31 20:13:30 2006
@@ -97,7 +97,7 @@
         refreshPresets()
 
     def createPreset(self, title=u'', uri=u''):
-        """Create a preset from the context.
+        """Create a preset from an element referred to by its URI.
         """
         context = self.context
         resources = getUtility(IResourceManager)
@@ -114,7 +114,7 @@
         resources.register(title=title, resource=resource, context=context)
 
     def usePreset(self, uri=u''):
-        """Use a preset specified by its URI
+        """Use a preset referred to by its URI
 
         The context is the display
 
@@ -146,7 +146,11 @@
                                   predicate=predicate)
         reltool.add(relation)
 
-    def stopUsingPreset(self):
+    def stopUsingPreset(self, uri=u''):
+        """Stop using a preset referred to by its URI
+
+        The context is the display.
+        """
         context = self.context
         if not uri:
             raise KeyError("Must specify a preset's URI.")
@@ -154,8 +158,26 @@
         if not IDisplay.providedBy(context):
             raise TypeError("The context must be a display.")
 
+        resources = getUtility(IResourceManager)
+        preset = resources.lookup(uri=uri, context=context)
+        if preset is None:
+            raise KeyError("No such preset: '%s'." % uri)
+
+        formats = getThemeManager(context).getFormatStorage()
+        resource = IResource(preset).getResource()
+
+        # remove the old display <-> preset relation
         reltool = IRelationTool(context)
-        # TODO
+        predicate = resource.predicate
+        old_rel = reltool.search(first=context, predicate=predicate)
+        reltool.remove(old_rel)
+
+        format = locationCopy(removeSecurityProxy(resource))
+        formats.add(format)
+
+        relation = DyadicRelation(first=context, second=format,
+                                  predicate=predicate)
+        reltool.add(relation)
 
     ### Sites  #########################################################
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to