Skip to content.

Etria Lists

 

[quills-dev] [Collective-checkins] r32311 - in Quills/trunk: . browser skins/Quills

quills-dev at lists.etria.com quills-dev at lists.etria.com
Wed Oct 25 15:12:32 UTC 2006


Author: tomster
Date: Wed Oct 25 15:12:30 2006
New Revision: 32311

Added:
   Quills/trunk/browser/commentViews.py
   Quills/trunk/browser/manage_comments.pt
Removed:
   Quills/trunk/skins/Quills/getComments.py
   Quills/trunk/skins/Quills/manage_comments.cpt
   Quills/trunk/skins/Quills/manage_comments.cpt.metadata
   Quills/trunk/skins/Quills/weblogcomments_validate_delete.vpy
   Quills/trunk/skins/Quills/weblogcomments_validate_update.vpy
Modified:
   Quills/trunk/configure.zcml
Log:
Migrated `manage_comments` to using a Five view. Other enhancements:

 * the main difference is that the listing of comments is now brains-based (as opposed to the previous object-based approach). This brings a noticeable performance gain!
 * entries are clickable links leading to the actual entry
 * added reset button to easily revert filters

Added: Quills/trunk/browser/commentViews.py
==============================================================================
--- (empty file)
+++ Quills/trunk/browser/commentViews.py	Wed Oct 25 15:12:30 2006
@@ -0,0 +1,81 @@
+from controllerView import FormControllerView, getToolByName
+
+class ManageCommentsView(FormControllerView):
+    """ The view class for the comments management form """
+    
+    def __init__(self, context, request):
+        super(ManageCommentsView, self).__init__(context, request)
+
+        self.form_submitted = bool(request.get('form.submitted'))
+        if bool(request.get('form.button.Delete')):
+            self.mode = "delete"
+        elif bool(request.get('form.button.Update')):
+            self.mode = "update"
+        elif bool(request.get('form.button.ResetFilter')):
+            self.mode = "reset"
+        else:
+            self.mode = 'display'
+
+        self.author = request.get('form.field.author', '')
+        self.subject = request.get('form.field.subject', '')
+        self.selected_comments = request.get('selected_comments', [])
+        self.portal_catalog = getToolByName(self.context,'portal_catalog')
+
+        self.contentFilter = {
+            'portal_type' : 'Discussion Item', 
+            'sort_on' : 'created', 
+            'sort_order' : 'reverse',
+            'path' : {'query' : '/'.join(self.context.getPhysicalPath()),}
+        }
+
+        self.filtered = False
+        if self.mode in ['delete', 'display', 'update']:
+            if self.author:
+                self.contentFilter['Creator'] = self.author
+                self.filtered = True
+            if self.subject:
+                self.contentFilter['Title'] = self.subject
+                self.filtered = True
+        if self.mode == "display":
+            self.getComments()
+
+    def validate(self):
+        """ performs validation and returns an errors dictionary """
+        errors = {}
+        if self.mode=='delete':
+            if self.selected_comments == []:
+                errors['status'] = 'failure'    # errors must not be empty...            
+                self.setMessage('You must select at least one comment for deletion.')
+                self.getComments()
+        return errors
+
+    def control(self):
+        """ performs the actions after a successful validation possibly
+            returning an errors dictionary """
+
+        if self.mode == "update":
+            self.setMessage('Filter applied.')
+        elif self.mode == "reset":
+            self.setMessage('Filter reset.')
+            self.author = None
+            self.subject = None
+        elif self.mode == "delete":
+            discussion_tool = getToolByName(self.context, 'portal_discussion')
+            for path in self.selected_comments:
+                self.deleteReply(discussion_tool, self.portal_catalog, path)
+            self.setMessage('%s comments have been deleted.' % str(len(self.selected_comments)))
+
+        self.getComments()
+        return {}
+            
+    def deleteReply(self, dtool, pcatalog, path):
+        discussion_item = pcatalog(path=path)[0].getObject()
+        obj = discussion_item.parentsInThread()[0]
+        discussion = dtool.getDiscussionFor(obj)
+        discussion.deleteReply(discussion_item.getId())
+
+    def getComments(self):
+        self.comment_brains = self.portal_catalog(self.contentFilter)
+        self.num_of_comments = len(self.comment_brains)
+        self.has_comments = self.num_of_comments > 0
+        
\ No newline at end of file

Added: Quills/trunk/browser/manage_comments.pt
==============================================================================
--- (empty file)
+++ Quills/trunk/browser/manage_comments.pt	Wed Oct 25 15:12:30 2006
@@ -0,0 +1,123 @@
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
+    lang="en"
+    i18n:domain="plone"
+    metal:use-macro="here/main_template/macros/master">
+      
+    <body>
+        <div metal:fill-slot="main">
+            <metal:contentsmacro 
+                define-macro="contents"
+                tal:define="errors options/state/getErrors | python: {};"
+            >
+
+                <div metal:use-macro="here/document_actions/macros/document_actions">
+                  Document actions (print, sendto etc)
+                </div>
+                <h1 i18n:translate="manage_comments">
+                  Manage Comments
+                </h1>
+        
+                <p class="discreet"
+                    i18n:translate="no_comments"
+                    tal:condition="not: view/has_comments">
+                  There are no comments for Weblog entries.
+                </p>
+
+                <metal:listing>
+                    <div class="visualClear" />
+                    <form name="commentsForm"
+                        method="post"
+                        tal:attributes="action request/ACTUAL_URL">
+                        <span i18n:translate="">Author</span>: <input type='text' name='form.field.author' size='10' tal:attributes='value view/author'/>
+                        <span i18n:translate="">Subject</span>: <input type='text' name='form.field.subject' size='20' tal:attributes='value view/subject'/>
+
+                        <input class="context"
+                            tabindex=""
+                            type="submit"
+                            name="form.button.Update"
+                            value="Update"
+                            i18n:attributes="value" />
+
+                        <input class="context"
+                            tal:condition="view/filtered"
+                            tabindex=""
+                            type="submit"
+                            name="form.button.ResetFilter"
+                            value="Reset"
+                            i18n:attributes="value" />
+                            
+                        <input class="context"
+                            tabindex=""
+                            type="submit"
+                            name="form.button.Delete"
+                            value="Delete"
+                            i18n:attributes="value" />
+                            
+                        <input type="hidden" name="form.submitted" value="1" /> 
+                        
+                        <table
+                            class="listing"
+                            summary="Comments listing"
+                            tal:condition="view/has_comments">
+                            <thead>
+                                <tr>
+                                    <th class="nosort">
+                                        <input class="noborder"
+                                            type="checkbox"
+                                            src="select_all_icon.gif"
+                                            name="selectButton"
+                                            title="Select all items"
+                                            onClick="toggleSelect(this,'selected_comments:list');"
+                                            tal:attributes="src string:$portal_url/select_all_icon.gif"
+                                            alt="Select all items"
+                                            i18n:attributes="title label_select_all_items; alt label_select_all_items;"
+                                            />
+                                    </th>
+                                    <th class="nosort">&nbsp;Date&nbsp;</th>
+                                    <th class="nosort">&nbsp;Author&nbsp;</th>
+                                    <th class="nosort">&nbsp;Subject&nbsp;</th>
+                                </tr>
+                            </thead>
+
+                            <tbody>
+                                <tal:items tal:repeat="comment view/comment_brains">
+                                    <tr tal:define="
+                                        comment_id           comment/id;
+                                        comment_path         comment/getPath;
+                                        comment_author       comment/Creator;
+                                        comment_subject      comment/Title;
+                                        comment_modified     comment/modified;
+                                        oddrow               repeat/comment/odd;"
+                                        tal:attributes="class python:view.test(oddrow, 'even', 'odd')" >
+
+                                        <td>
+                                            <input type="checkbox"
+                                                class="noborder"
+                                                name="selected_comments:list" id="#"
+                                                value="#"
+                                                tal:attributes="
+                                                    value   comment_path;
+                                                    id      string:cb_$comment_id;
+                                                    checked python:view.test(request.get('ids_checked', False), 'checked', None);
+                                                    alt     string:Select $comment_subject;
+                                                    title   string:Select $comment_subject;" />
+
+                                        </td>
+
+                                        <td tal:content="python:here.toLocalizedTime(comment_modified, long_format=1)">
+                                            08/19/2001 03:01 AM
+                                        </td>
+                                        <td> <a tal:attributes="href comment_path" tal:content="comment_author" /></td>
+                                        <td> <a tal:attributes="href comment_path" tal:content="comment_subject" /></td>
+
+                                    </tr>
+                                </tal:items>
+                            </tbody>
+                        </table>
+                    </form>
+                </metal:listing>
+            </metal:contentsmacro>
+        </div>
+    </body>
+</html>
+

Modified: Quills/trunk/configure.zcml
==============================================================================
--- Quills/trunk/configure.zcml	(original)
+++ Quills/trunk/configure.zcml	Wed Oct 25 15:12:30 2006
@@ -30,6 +30,13 @@
       name="topics" />
 
   <browser:page
+      for=".interfaces.IWeblog"
+      template="browser/manage_comments.pt"
+      permission="zope2.View"
+      class=".browser.commentViews.ManageCommentsView"
+      name="manage_comments" />
+
+  <browser:page
       for=".interfaces.ITopic"
       template="browser/topic_view.pt"
       permission="zope2.View"

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Collective-checkins mailing list
Collective-checkins at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/collective-checkins



More information about the quills-dev mailing list