[CMF-checkins] SVN: CMF/trunk/C - refactored and improved discussion_reply_form

Yvo Schubbe y.2006_ at wcm-solutions.de
Mon Jan 30 12:20:13 EST 2006


Log message for revision 41500:
  - refactored and improved discussion_reply_form
  - added two missing strings to cmf_default-manual.pot
  - updated cmf_default.pot

Changed:
  U   CMF/trunk/CHANGES.txt
  U   CMF/trunk/CMFDefault/locales/cmf_default-manual.pot
  U   CMF/trunk/CMFDefault/locales/cmf_default.pot
  UU  CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py
  D   CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.pt
  A   CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py
  D   CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_preview.pt
  A   CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_template.pt

-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CHANGES.txt	2006-01-30 17:20:13 UTC (rev 41500)
@@ -128,6 +128,8 @@
 
   Bug Fixes
 
+    - CMFDefault skins: Refactored and improved discussion_reply_form.
+
     - CMFDefault utils: Fixed html_marshal function.
       The return values are no longer escaped to avoid double quoting and no
       longer stringified. The page templates take care of these steps.

Modified: CMF/trunk/CMFDefault/locales/cmf_default-manual.pot
===================================================================
--- CMF/trunk/CMFDefault/locales/cmf_default-manual.pot	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CMFDefault/locales/cmf_default-manual.pot	2006-01-30 17:20:13 UTC (rev 41500)
@@ -27,3 +27,9 @@
 
 msgid "Local Roles"
 msgstr ""
+
+msgid "Retract"
+msgstr ""
+
+msgid "Submit"
+msgstr ""

Modified: CMF/trunk/CMFDefault/locales/cmf_default.pot
===================================================================
--- CMF/trunk/CMFDefault/locales/cmf_default.pot	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CMFDefault/locales/cmf_default.pot	2006-01-30 17:20:13 UTC (rev 41500)
@@ -13,7 +13,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: CMF 2.0\n"
-"POT-Creation-Date: Fri Jan 27 11:59:42 2006\n"
+"POT-Creation-Date: Mon Jan 30 18:05:55 2006\n"
 "Language-Team: CMF Developers <zope-cmf at zope.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
@@ -77,8 +77,6 @@
 msgstr ""
 
 #: CMFDefault/profiles/default/actions.xml:113
-#: CMFDefault/skins/zpt_generic/discussion_reply_form.pt:32
-#: CMFDefault/skins/zpt_generic/discussion_reply_preview.pt:24
 msgid "Reply"
 msgstr ""
 
@@ -487,11 +485,6 @@
 msgid "Upload"
 msgstr ""
 
-#: CMFDefault/skins/zpt_content/document_edit_template.pt:48
-#: CMFDefault/skins/zpt_generic/discussion_reply_preview.pt:21
-msgid "Edit"
-msgstr ""
-
 #: CMFDefault/skins/zpt_content/document_edit_template.pt:5
 #: CMFDefault/skins/zpt_content/file_edit_template.pt:5
 #: CMFDefault/skins/zpt_content/folder_edit_template.pt:5
@@ -933,18 +926,28 @@
 msgid "Created by"
 msgstr ""
 
-#: CMFDefault/skins/zpt_generic/discussion_reply_form.pt:14
-msgid "Subject (Title)"
+#: CMFDefault/skins/zpt_generic/discussion_reply_form.py:38
+#: CMFDefault/skins/zpt_generic/folder_factories_template.pt:36
+msgid "Add"
 msgstr ""
 
-#: CMFDefault/skins/zpt_generic/discussion_reply_form.pt:21
-msgid "Reply body"
+#: CMFDefault/skins/zpt_generic/discussion_reply_form.py:40
+#: CMFDefault/skins/zpt_content/document_edit_template.pt:48
+msgid "Edit"
 msgstr ""
 
-#: CMFDefault/skins/zpt_generic/discussion_reply_form.pt:29
+#: CMFDefault/skins/zpt_generic/discussion_reply_form.py:42
 msgid "Preview"
 msgstr ""
 
+#: CMFDefault/skins/zpt_generic/discussion_reply_template.pt:16
+msgid "Subject (Title)"
+msgstr ""
+
+#: CMFDefault/skins/zpt_generic/discussion_reply_template.pt:22
+msgid "Reply body"
+msgstr ""
+
 #: CMFDefault/skins/zpt_generic/folder_contents.py:109
 #: CMFDefault/skins/zpt_generic/metadata_help.pt:114
 #: CMFDefault/skins/zpt_generic/review.pt:29
@@ -1032,10 +1035,6 @@
 msgid "ID:"
 msgstr ""
 
-#: CMFDefault/skins/zpt_generic/folder_factories_template.pt:36
-msgid "Add"
-msgstr ""
-
 #: CMFDefault/skins/zpt_generic/folder_factories_template.pt:5
 msgid "Add Content"
 msgstr ""
@@ -1907,3 +1906,9 @@
 
 msgid "Local Roles"
 msgstr ""
+
+msgid "Retract"
+msgstr ""
+
+msgid "Submit"
+msgstr ""

Modified: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py	2006-01-30 17:20:13 UTC (rev 41500)
@@ -1,12 +1,12 @@
-## Script (Python) "discussion_reply"
-##parameters=title,text
+##parameters=title, text, **kw
 ##title=Reply to content
+##
+from Products.CMFCore.utils import getToolByName
 
-replyID = context.createReply( title = title
-                             , text = text
-                             )
+dtool = getToolByName(script, 'portal_discussion')
+talkback = dtool.getDiscussionFor(context)
+replyID = talkback.createReply(title=title, text=text)
 
-target = '%s/%s' % (context.absolute_url(), replyID)
+target = '%s/%s' % (talkback.absolute_url(), replyID)
 
 context.REQUEST.RESPONSE.redirect(target)
-


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py
___________________________________________________________________
Name: svn:keywords
   - Author Date Id Revision

Deleted: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.pt
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.pt	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.pt	2006-01-30 17:20:13 UTC (rev 41500)
@@ -1,41 +0,0 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="here/main_template/macros/master">
-<body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-<tal:block define="dummy python:here.portal_discussion.getDiscussionFor(here)" />
-
-<form method="post" action="talkback"
-      tal:attributes="action string:${here/absolute_url}/talkback">
-<input type="hidden" name=":default_method" value="discussion_reply" />
-
-<table class="FormLayout">
- <tr>
-  <th align="left" i18n:translate="">Subject (Title)</th>
-  <td><input name="title" value=""
-             tal:attributes="value request/form/title|here/title" />
-  </td>
- </tr>
- <tr>
-  <td colspan="2">
-   <b i18n:translate="">Reply body</b><br />
-   <textarea name="text" cols="70" rows="10" wrap="soft" style="width: 100%"
-             tal:content="request/form/text|nothing"></textarea>
-  </td>
- </tr>
- <tr>
-  <td></td>
-  <td>
-   <input type="submit" value="Preview" name=""
-          tal:attributes="name string:${here/getId}/discussion_reply_preview:method"
-          i18n:attributes="value" />
-   <input type="submit" value="Reply" name=""
-          tal:attributes="name string:discussion_reply:method"
-          i18n:attributes="value" />
-  </td>
- </tr>
-</table>
-</form>
-</div>
-</body>
-</html>

Added: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py	2006-01-30 17:20:13 UTC (rev 41500)
@@ -0,0 +1,47 @@
+##parameters=add='', edit='', preview=''
+##
+from Products.PythonScripts.standard import structured_text
+from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.utils import html_marshal
+from Products.CMFDefault.utils import Message as _
+
+atool = getToolByName(script, 'portal_actions')
+
+
+form = context.REQUEST.form
+is_preview = False
+if add and \
+        context.validateHTML(**form) and \
+        context.discussion_reply(**form):
+    return
+elif preview and \
+        context.validateHTML(**form):
+    is_preview = True
+
+
+options = {}
+
+title = form.get('title', context.Title())
+text = form.get('text', '')
+options['is_preview'] = is_preview
+options['title'] = title
+options['text'] = text
+options['cooked_text'] = structured_text(text)
+
+if is_preview:
+    hidden_vars = [ {'name': n, 'value': v}
+                    for n, v in html_marshal(title=title, text=text) ]
+else:
+    hidden_vars = []
+buttons = []
+target = atool.getActionInfo('object/reply', context)['url']
+buttons.append( {'name': 'add', 'value': _(u'Add')} )
+if is_preview:
+    buttons.append( {'name': 'edit', 'value': _(u'Edit')} )
+else:
+    buttons.append( {'name': 'preview', 'value': _(u'Preview')} )
+options['form'] = { 'action': target,
+                    'listHiddenVarInfos': tuple(hidden_vars),
+                    'listButtonInfos': tuple(buttons) }
+
+return context.discussion_reply_template(**options)


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_preview.pt
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_preview.pt	2006-01-30 17:07:51 UTC (rev 41499)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_preview.pt	2006-01-30 17:20:13 UTC (rev 41500)
@@ -1,31 +0,0 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="here/main_template/macros/master">
-<body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
-
-<h3 tal:content="request/form/title"></h3>
-
-<div tal:define="pss modules/Products.PythonScripts.standard"
-     tal:replace="structure python: pss.structured_text(request.form['text'])">Text Body</div>
-
-<form method="post" action="talkback"
-      tal:attributes="action string:${here/absolute_url}/talkback">
- <input type="hidden" name="title" value=""
-        tal:attributes="value request/form/title" />
- <input type="hidden" name="text" value=""
-        tal:attributes="value request/form/text" />
- <table><tr>
-  <td width="15%"></td>
-  <td>
-   <input type="submit" value="Edit" name=""
-          tal:attributes="name string:${here/getId}/discussion_reply_form:method"
-          i18n:attributes="value" />
-   <input type="submit" value="Reply" name="discussion_reply:method"
-          i18n:attributes="value" />
-  </td>
- </tr></table>
-</form>
-</div>
-</body>
-</html>

Copied: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_template.pt (from rev 41453, CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.pt)
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.pt	2006-01-26 16:36:28 UTC (rev 41453)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_template.pt	2006-01-30 17:20:13 UTC (rev 41500)
@@ -0,0 +1,39 @@
+<html metal:use-macro="context/main_template/macros/master">
+<body>
+
+<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
+   tal:define="form options/form">
+<tal:case tal:condition="options/is_preview">
+<h3 tal:content="options/title">TITLE</h3>
+
+<tal:span tal:replace="structure options/cooked_text">Text Body</tal:span>
+</tal:case>
+<form action="discussion_reply_form" method="post"
+   tal:attributes="action form/action"
+><metal:macro metal:use-macro="context/form_widgets/macros/hidden_vars" />
+<table class="FormLayout">
+ <tr tal:condition="not:options/is_preview">
+  <th i18n:translate="">Subject (Title)</th>
+  <td>
+   <input name="title" value="" tal:attributes="value options/title" />
+  </td>
+ </tr>
+ <tr tal:condition="not:options/is_preview">
+  <th i18n:translate="">Reply body</th>
+  <td>
+   <textarea name="text" cols="70" rows="10" wrap="soft" style="width: 100%"
+      tal:content="options/text"></textarea>
+  </td>
+ </tr>
+ <tr>
+  <td>&nbsp;</td>
+  <td>
+   <metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
+  </td>
+ </tr>
+</table>
+</form>
+</metal:slot>
+
+</body>
+</html>


Property changes on: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_template.pt
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the CMF-checkins mailing list