Changeset 219

Show
Ignore:
Timestamp:
01/31/06 06:23:18
Author:
mylan
Message:

Raise publishing reliability.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/trunk/skins/qplonecomments/discussion_publish_comment.py

    r218 r219  
    55##bind script=script 
    66##bind subpath=traverse_subpath 
    7 ##parameters=reply=None 
     7##parameters=obj=None 
    88##title= 
    99## 
    1010from Products.CMFPlone import transaction_note 
    11 from Products.qPloneComments.utils import publishDiscussion 
    1211from Products.qPloneComments.utils import publishDiscussion, send_email 
    1312 
    14 if reply is None: 
    15     reply=context 
     13if obj is None: 
     14    obj=context 
    1615 
    17 # Publish discussion item 
    18 publishDiscussion(context) 
     16parent = obj.inReplyTo() 
     17if parent is not None: 
     18    talkback = context.portal_discussion.getDiscussionFor(parent) 
     19else: 
     20    talkback = parent = obj.aq_parent 
    1921 
    20 # Send notification e-mail 
     22reply = talkback.getReply( obj.getId() ) 
     23publishDiscussion(reply) 
     24 
    2125send_notification_message = send_email(reply, container, state="published") 
    2226 
    23 # Inform user about awaiting moderation 
    2427portal_status_message='Comment+successfully+published' 
    2528 
  • qPloneComments/trunk/tests/testQPloneCommentsModeration.py

    r218 r219  
    149149 
    150150 
    151     def testPublishing(self): 
     151    def __testPublishing(self): 
    152152        # Check whether perform real publishing 
    153153        for u in DM_USERS_IDS: 
     
    165165            self.logout() 
    166166            self.assert_(getReplies(), "%s - member of DiscussionManager group NOT PUBLISH reply" % u) 
     167 
     168 
     169    def testPublishing(self): 
     170        # Check whether perform real publishing 
     171        # Pattern for publish button presence checking 
     172        pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 
     173                             re.S|re.M) 
     174        for u in DM_USERS_IDS: 
     175            doc_id = "doc_%s" % u 
     176            doc_obj = getattr(self.portal, doc_id) 
     177            getReplies = self.discussion.getDiscussionFor(doc_obj).getReplies 
     178            # Check whether anonymous get no reply 
     179            self.logout() 
     180            self.assert_(not getReplies(), "View not published reply ALLOW for Anonymous") 
     181            # Login with actual (tested) user with DiscussionManager role and publish discussion 
     182            self.login(u) 
     183            self.assert_(getReplies(), "%s - member of DiscussionManager group NOT VIEW not published reply" % u) 
     184            getReplies()[0].discussion_publish_comment() 
     185            # Check if Publish button still present in document view page 
     186            auth = "%s:" % u 
     187            if not u=='anonym': 
     188                auth = '%s:%s' % (u,USERS[u]['passw']) 
     189            html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 
     190            m = pattern.match(html) 
     191            self.assert_(not m, "Publish button present for %s - DiscussionManager role user after publishing" % u) 
     192            # Check whether Anonym view published reply 
     193            self.logout() 
     194            self.assert_(getReplies(), "%s - member of DiscussionManager group NOT PUBLISH reply" % u) 
     195 
    167196 
    168197