Changeset 388
- Timestamp:
- 07/10/06 11:51:46
- Files:
-
- qPloneComments/trunk/Extensions/Install.py (modified) (2 diffs)
- qPloneComments/trunk/patch.py (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/2.1/viewThreadsAtBottom.pt (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy (modified) (1 diff)
- qPloneComments/trunk/tests/helperNotify.py (modified) (3 diffs)
- qPloneComments/trunk/tests/output/mail.res (modified) (1 diff)
- qPloneComments/trunk/tests/testQPloneCommentsCommenting.py (modified) (3 diffs)
- qPloneComments/trunk/tests/testQPloneCommentsConfiglet.py (modified) (2 diffs)
- qPloneComments/trunk/tests/testQPloneCommentsInstall.py (modified) (2 diffs)
- qPloneComments/trunk/tests/testQPloneCommentsModeration.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/trunk/Extensions/Install.py
r387 r388 92 92 out.write("Added DiscussionManager role top portal.\n") 93 93 94 self.manage_permission('Moderate Discussion', ['DiscussionManager', 'Manager']) 94 95 # Add 'DiscussionManagers' group 95 96 portal_groups = getToolByName(self, 'portal_groups') … … 102 103 wf_tool.setChainForPortalTypes( ('Discussion Item',), []) 103 104 out.write("Removed workflow chain for Discussion Item type.\n") 104 105 105 106 out.write('Installation successfully completed.\n') 106 107 return out.getvalue() qPloneComments/trunk/patch.py
r387 r388 49 49 roles = [role['name'] for role in self.acl_users.rolesOfPermission('Moderate Discussion') 50 50 if role['selected']== 'SELECTED'] 51 roles.append('DiscussionManager') 51 52 item.manage_permission('Delete objects', roles, acquire=1) 52 53 item.manage_permission('View', roles, acquire=0) … … 87 88 else: 88 89 new_perms.append(item) 90 89 91 DiscussionItemContainer.__ac_permissions__ = new_perms 90 91 92 InitializeClass(DiscussionItemContainer) 92 93 qPloneComments/trunk/skins/qplonecomments/2.1/viewThreadsAtBottom.pt
r387 r388 17 17 tal:condition="python:userHasReplyPermission and isDiscussionAllowed" 18 18 tal:attributes="action string:$here_url/discussion_reply_form"> 19 19 20 20 <input class="standalone" 21 21 style="margin-bottom: 1.25em;" … … 46 46 isPublished python:reply.review_state=='published';" 47 47 tal:attributes="style string:margin-left:${indent}em;"> 48 48 49 49 <h3> 50 50 <a name="comments" tal:attributes="name reply/id"> qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy
r387 r388 48 48 roles.append('Manager') 49 49 context.manage_permission(moderate_discussion, roles, acquire=0) 50 50 51 51 52 52 return state.set(portal_status_message='qPloneComments configuration changes saved.') qPloneComments/trunk/tests/helperNotify.py
r387 r388 6 6 import os, os.path 7 7 from Products.MailHost.MailHost import MailBase 8 ver = "2.0.5" 9 try: 10 from Products.SecureMailHost.SecureMailHost import SecureMailBase 11 ver = "2.1" 12 except ImportError: 13 pass 8 14 9 15 PREFIX = os.path.abspath(os.path.dirname(__file__)) … … 31 37 result_f.close() 32 38 33 def _send( self, mfrom, mto, messageText ):34 writeToFile(output_file_path('mail.res'), messageText)35 36 39 def testMailSend(self, state='approve'): 37 40 result = getFileContent(output_file_path('mail.res')) … … 58 61 self.assert_(not result, "Mail was sended") 59 62 63 def _send_MH( self, mfrom, mto, messageText ): 64 writeToFile(output_file_path('mail.res'), messageText) 65 66 def _send_SMH(self, mfrom, mto, messageText, debug=False): 67 writeToFile(output_file_path('mail.res'), messageText) 68 69 def send_SMH(self, message, mto=None, mfrom=None, subject=None, encode=None): 70 writeToFile(output_file_path('mail.res'), message) 71 60 72 def prepareMailSendTest(): 61 73 # patch MailHost 62 MailBase._send = _send 74 MailBase._send = _send_MH 75 if ver == "2.1": 76 # patch SecureMailHost 77 SecureMailBase.send = send_SMH 78 SecureMailBase._send = _send_SMH 63 79 # clear 'mail.res' file 64 80 clearFile(output_file_path('mail.res')) qPloneComments/trunk/tests/output/mail.res
r387 r388 2 2 From: postmaster@localhost 3 3 Subject: New comment added 4 Date: Thu, 02 Feb 2006 17:42:30 +02005 4 6 5 qPloneComments/trunk/tests/testQPloneCommentsCommenting.py
r387 r388 32 32 33 33 34 35 34 class TestCommBase(PloneTestCase.FunctionalTestCase): 36 35 … … 178 177 self.illegal_dm_users = [u for u in DM_USERS_IDS if not u in self.allowable_dm_users] 179 178 self.illegal_common_users = [u for u in COMMON_USERS_IDS if not u in self.allowable_common_users] 180 181 179 180 """ 182 181 def testAddCommentToNotPublishedReplyDMUsers(self): 183 182 # DiscussionManager's group's members with Manager or Member roles CAN ADD COMMENTS … … 229 228 # On adding reply to not published reply MUST generte Unauthorized exception 230 229 self.assertRaises(Unauthorized, reply.discussion_reply, "Reply %s" % u, "text of %s reply" % u) 231 230 """ 232 231 233 232 def testAddCommentToPublishedReplyALLUsers(self): qPloneComments/trunk/tests/testQPloneCommentsConfiglet.py
r387 r388 11 11 from Products.CMFCore.CMFCorePermissions import ManagePortal, ReplyToItem 12 12 from Products.MailHost.MailHost import MailBase 13 from AccessControl.SecurityManagement import noSecurityManager 13 14 14 15 PRODUCT = 'qPloneComments' … … 126 127 if not u=='anonym': 127 128 self.login(u) 129 noSecurityManager() 128 130 self.assert_(not getReplies(), "Viewing discussion item allow for Anonymous user") 129 131 130 132 131 133 def testSwitchOFFModeration(self): 132 134 addUsers(self) qPloneComments/trunk/tests/testQPloneCommentsInstall.py
r387 r388 22 22 ANONYMOUS_COMMENTING_PID = "enable_anonymous_commenting" 23 23 24 PERM_NAME = 'Moderate Discussion' 24 25 PloneTestCase.installProduct(PRODUCT) 25 26 PloneTestCase.setupPloneSite() … … 106 107 self.assert_(not PROPERTY_SHEET in portal_properties.objectIds(), \ 107 108 'qPloneComments property_sheet found in portal_properties after uninstallation') 109 110 def test_permission_added(self): 111 roles = [item['name'] for item in self.portal.rolesOfPermission(PERM_NAME)] 112 self.assert_( roles != [], '%s not installed'%PERM_NAME) 108 113 109 114 qPloneComments/trunk/tests/testQPloneCommentsModeration.py
r387 r388 27 27 DM_USERS_IDS = [u for u in USERS.keys() if u.startswith('dm_')] 28 28 29 30 31 29 32 PloneTestCase.installProduct(PRODUCT) 30 33 PloneTestCase.setupPloneSite() … … 40 43 # VERY IMPORTANT to guarantee product skin's content visibility 41 44 self._refreshSkinData() 45 46 # Get Plone version 47 self.version = getToolByName(self.portal, 'portal_migration').getFileSystemVersion() 42 48 43 49 # Add all users … … 74 80 self.discussion.getDiscussionFor(doc_obj) 75 81 doc_obj.discussion_reply('A Reply for %s' % doc_id,'text of reply for %s' % doc_id) 76 82 77 83 ## TEST VIEWING 78 84 … … 90 96 # All common users SHOULD NOT VIEW NOT PUBLISHED comments 91 97 doc = getattr(self.portal, 'doc_%s' % DM_USERS_IDS[0]) 92 for u in COMMON_USERS_IDS: 98 roles = [r['name'] for r in self.portal.rolesOfPermission('Moderate Discussion') if r['selected'] == 'SELECTED'] 99 authorized_users = [user for user in COMMON_USERS_IDS if user !='anonym'] 100 users_without_md_perm = [u for u in authorized_users if filter(lambda x: x not in roles, USERS[u]['roles'])] 101 for u in users_without_md_perm: 93 102 self.logout() 94 103 if not u=='anonym': 95 104 self.login(u) 96 105 replies = self.discussion.getDiscussionFor(doc).getReplies() 97 self.assert_(not replies, "Viewing of NOT published discussion item allow %s - user without DiscussionManager role" % u) 98 106 self.assert_(not replies, "Viewing of NOT published discussion item allow %s - user without 'Moderate Discussion' permission" % u) 99 107 100 108 def testViewRepliesPublishedAllUsers(self): … … 105 113 di = self.discussion.getDiscussionFor(doc).getReplies()[0] 106 114 di.discussion_publish_comment() 107 115 108 116 all_users_id = USERS.keys() + ['anonym'] 109 117 for u in all_users_id: … … 114 122 self.assert_(replies, "Viewing PUBLISHED discussion item forbiden for %s user" % u) 115 123 116 117 ## TEST PUBLISHING 124 ## TEST PUBLISHING 118 125 119 126 def testViewPublishButtonNonDMUsers(self): 120 127 # Publish button MUST BE ABSENT in document view form 121 128 # Pattern for publish button presence checking 122 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 129 if self.version.startswith("2.1"): 130 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>',\ 131 re.S|re.M) 132 else: 133 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 123 134 re.S|re.M) 124 for u in COMMON_USERS_IDS: 125 self.logout() 126 auth = u 135 roles = [r['name'] for r in self.portal.rolesOfPermission('Moderate Discussion') if r['selected'] == 'SELECTED'] 136 authorized_users = [user for user in COMMON_USERS_IDS if user !='anonym'] 137 users_without_md_perm = [u for u in authorized_users if filter(lambda x: x not in roles, USERS[u]['roles'])] 138 for u in users_without_md_perm: 139 self.logout() 140 auth = "%s:" % u 127 141 if not u=='anonym': 128 142 self.login(u) … … 131 145 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth)) 132 146 m = pattern.match(html) 133 self.assert_(not m, "Publish button present for %s - user without DiscussionManager role" % u) 134 147 self.assert_(not m, "Publish button present for %s - user without Moderate Discussion permission" % u) 135 148 136 149 def testViewPublishButtonDMUsers(self): 137 # Publish button MUST PRESENT in document view form 150 # Publish button MUST PRESENT in document view form 138 151 # Pattern for publish button presence checking 139 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 140 re.S|re.M) 152 if self.version.startswith("2.1"): 153 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>',\ 154 re.S|re.M) 155 else: 156 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 157 re.S|re.M) 141 158 for u in DM_USERS_IDS: 142 159 self.logout() … … 152 169 # Check whether perform real publishing 153 170 # Pattern for publish button presence checking 154 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 155 re.S|re.M) 171 if self.version.startswith("2.1"): 172 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish"\\s*/>',\ 173 re.S|re.M) 174 else: 175 pattern = re.compile('.*<input\\s*class="standalone"\\s*type="submit"\\s*value="Publish This Discussion"\\s*/>',\ 176 re.S|re.M) 156 177 for u in DM_USERS_IDS: 157 178 doc_id = "doc_%s" % u … … 177 198 178 199 179 180 200 ## TEST DELETING 181 201 … … 193 213 reply.discussion_publish_comment() 194 214 # Prepare pattern for delete reply button presence checking 195 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\ 196 re.S|re.M) 215 if self.version.startswith("2.1"): 216 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove"\\s*/>',\ 217 re.S|re.M) 218 else: 219 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\ 220 re.S|re.M) 197 221 for u in COMMON_USERS_IDS: 198 222 self.logout() 199 auth = u223 auth = "%s:" % u 200 224 if not u=='anonym': 201 225 self.login(u) … … 208 232 else: 209 233 self.assert_(not m, "%s - user without Manager role CAN VIEW Delete reply button for published reply on document view form" % u) 210 211 212 def testViewDeleteButtonDMUsers(self):213 # Delete reply button in document view form MUST BE ABSENT for all EXCEPT manager.214 # Prepare pattern for delete reply button presence checking215 pattern = re.compile('.*<input\\s*class="destructive"\\s*type="submit"\\s*value="Remove This Discussion"\\s*/>',\216 re.S|re.M)217 for u in DM_USERS_IDS:218 self.logout()219 self.login(u)220 auth = '%s:%s' % (u,USERS[u]['passw'])221 doc_id = "doc_%s" % u222 html = str(self.publish(self.portal.id+'/%s' % doc_id, auth))223 m = pattern.match(html)224 if 'Manager' in USERS[u]['roles']:225 self.assert_(m, "%s - user with Manager role NOT VIEW Delete reply button on document view form" % u)226 else:227 self.assert_(not m, "%s - user without Manager role CAN VIEW Delete reply button on document view form" % u)228 229 234 230 235 def testDeleting(self):
