Author: jmorliaguet
Date: Mon Jun 19 12:01:01 2006
New Revision: 3459

Modified:
   cpsskins/branches/paris-sprint-2006/ui/screens/common/page_tabs.pt
   cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py
   cpsskins/branches/paris-sprint-2006/utils.py

Log:

- fixes, when adding pages and themes via the editor



Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/page_tabs.pt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/page_tabs.pt  
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/page_tabs.pt  Mon Jun 
19 12:01:01 2006
@@ -10,5 +10,5 @@
       <a tal:content="python: page.title or 'No title'"
          tal:attributes="href 
string:@@setWorkPage?name=${theme/name}:${page/name}" /></li>
   </tal:block>
-  <li><a href="./@@addPage">+</a></li>
+  <li><a tal:attributes="href 
string:./@@addPage?theme_name=${theme/name}">+</a></li>
 </ul>

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py      Mon Jun 
19 12:01:01 2006
@@ -44,7 +44,7 @@
 from cpsskins.elements.interfaces import IInnerNode, IFormattable
 from cpsskins.setup.interfaces import IResourceManager, IIdentifiable, IType
 from cpsskins.ui.screens.definitions import MODELS, VIEWS, CONTROLLERS
-from cpsskins.utils import getThemeManager
+from cpsskins.utils import getThemeManager, addThemeSkeleton, addPageSkeleton
 from cpsskins.standard.filters.style.css import IStylesheetView
 
 _ = MessageFactory("cpsskins")
@@ -246,21 +246,18 @@
         """Add a theme.
         """
         response = self.request.response
-        theme = Theme()
-        self.tmutil.addTheme(theme)
-        page = ThemePage()
-        self.tmutil.addPage(theme, page)
+        addThemeSkeleton(self.tmutil)
         response.redirect('.')
 
-    def addPage(self):
-        """Add a page.
+    def addPage(self, theme_name=u''):
+        """Add a page. 'theme_name' is the name of the theme in which is page 
is
+        added.
         """
         response = self.request.response
-        negotiation = getMultiAdapter((self.context, self.request),
-                                      INegotiation, 'negotiation')
-        theme = negotiation.getPage().theme
-        page = ThemePage()
-        self.tmutil.addPage(theme, page)
+        theme = self.tmutil.getThemeByName(theme_name)
+        if theme is None:
+            raise ValueError("No such theme: %s" % theme_name)
+        addPageSkeleton(self.tmutil, theme)
         response.redirect('.')
 
 

Modified: cpsskins/branches/paris-sprint-2006/utils.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/utils.py        (original)
+++ cpsskins/branches/paris-sprint-2006/utils.py        Mon Jun 19 12:01:01 2006
@@ -76,16 +76,19 @@
 
 def addThemeSkeleton(context):
     # for testing purposes
-    from cpsskins.elements.interfaces import IFormattable
     from cpsskins.elements.theme import Theme
+    theme = Theme()
+    name = context.addTheme(theme)
+    theme.title = name.replace('-', ' ')
+    page = addPageSkeleton(context, theme)
+    return theme
+
+def addPageSkeleton(context, theme):
     from cpsskins.elements.themepage import ThemePage
     from cpsskins.elements.pageblock import PageBlock
     from cpsskins.elements.cell import Cell
     from cpsskins.elements.slot import Slot
-
-    theme = Theme()
-    name = context.addTheme(theme)
-    theme.title = name.replace('-', ' ')
+    from cpsskins.elements.interfaces import IFormattable
 
     # Add a page
     page = ThemePage(u'Default page')
@@ -117,7 +120,7 @@
     set_width(page[u'main'][u'main'], u'60%')
     set_width(page[u'main'][u'right'], u'20%')
 
-    return theme
+    return page
 
 def camelize(text):
     res = []
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to