Changeset 242
- Timestamp:
- 02/02/06 07:58:47
- Files:
-
- qPloneComments/trunk/Extensions/Install.py (modified) (4 diffs)
- qPloneComments/trunk/config.py (modified) (1 diff)
- qPloneComments/trunk/patch.py (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/discussion_publish_comment.py (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/discussion_reply.cpy (modified) (4 diffs)
- qPloneComments/trunk/skins/qplonecomments/discussion_reply_form.cpt (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup_form.cpt (modified) (8 diffs)
- qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_delete.cpy (added)
- qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_delete.cpy.metadata (added)
- qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_form.cpt (added)
- qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_form.cpt.metadata (added)
- qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_publish.cpy (added)
- qPloneComments/trunk/skins/qplonecomments/prefs_recent_comments_publish.cpy.metadata (added)
- qPloneComments/trunk/skins/qplonecomments/validate_setup.vpy (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/validate_talkback.vpy (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/viewThreadsAtBottom.pt (modified) (3 diffs)
- qPloneComments/trunk/tests/testQPloneCommentsCommenting.py (modified) (5 diffs)
- qPloneComments/trunk/tests/testQPloneCommentsConfiglet.py (modified) (6 diffs)
- qPloneComments/trunk/tests/testQPloneCommentsInstall.py (modified) (1 diff)
- qPloneComments/trunk/tests/testQPloneCommentsNotification.py (modified) (6 diffs)
- qPloneComments/trunk/utils.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/trunk/Extensions/Install.py
r241 r242 45 45 # add Property sheet to portal_properies 46 46 pp = getToolByName(self, 'portal_properties') 47 if not PROPERTY_SHEETin pp.objectIds():48 pp.addPropertySheet(id= PROPERTY_SHEET, title= '%s Properties' % PROPERTY_SHEET)49 out.write("Adding %s property sheet to portal_properies\n" % PROPERTY_SHEET)50 props_sheet = pp[ PROPERTY_SHEET]51 updateProperty(props_sheet, id=" Enable_Moderation", value="True", property_type='boolean', out=out)52 updateProperty(props_sheet, id=" Enable_Anonymous_Commenting", value="True", property_type='boolean', out=out)53 updateProperty(props_sheet, id=" Enable_Published_Notification", value="True", property_type='boolean', out=out)54 updateProperty(props_sheet, id=" Enable_Approve_Notification", value="True", property_type='boolean', out=out)55 updateProperty(props_sheet, id=" Email_Discussion_Manager", value="", property_type='string', out=out)56 updateProperty(props_sheet, id=" Email_Subject_Prefix", value="", property_type='string', out=out)47 if not 'qPloneComments' in pp.objectIds(): 48 pp.addPropertySheet(id='qPloneComments', title= '%s Properties' % 'qPloneComments') 49 out.write("Adding %s property sheet to portal_properies\n" % 'qPloneComments' ) 50 props_sheet = pp['qPloneComments'] 51 updateProperty(props_sheet, id="enable_moderation", value="True", property_type='boolean', out=out) 52 updateProperty(props_sheet, id="enable_anonymous_commenting", value="True", property_type='boolean', out=out) 53 updateProperty(props_sheet, id="enable_published_notification", value="True", property_type='boolean', out=out) 54 updateProperty(props_sheet, id="enable_approve_notification", value="True", property_type='boolean', out=out) 55 updateProperty(props_sheet, id="email_discussion_manager", value="", property_type='string', out=out) 56 updateProperty(props_sheet, id="email_subject_prefix", value="", property_type='string', out=out) 57 57 # Tern on Anonymous commenting 58 58 self.manage_permission(ReplyToItem, ['Anonymous','Manager','Member'], 1) 59 59 60 out.write("Updating properties of %s property sheet\n" % PROPERTY_SHEET)60 out.write("Updating properties of %s property sheet\n" % 'qPloneComments' ) 61 61 62 62 # Add Configlet. Delete old version before adding, if exist one. … … 69 69 # Add DiscussionManager role to Portal 70 70 roles = list(self.__ac_roles__) 71 roles.append( 'DiscussionManager' ) 72 roles = tuple(roles) 73 self.__ac_roles__ = roles 74 out.write("Added DiscussionManager role top portal.\n") 71 if not 'DiscussionManager' in roles: 72 roles.append( 'DiscussionManager' ) 73 roles = tuple(roles) 74 self.__ac_roles__ = roles 75 out.write("Added DiscussionManager role top portal.\n") 75 76 76 77 # Add 'DiscussionManagers' group 77 78 portal_groups = getToolByName(self, 'portal_groups') 78 portal_groups.addGroup('DiscussionManager', roles=['DiscussionManager']) 79 out.write("Added DiscussionManagers group to portal_groups with DiscussionManager role.\n") 79 if not 'DiscussionManager' in portal_groups.listGroupIds(): 80 portal_groups.addGroup('DiscussionManager', roles=['DiscussionManager']) 81 out.write("Added DiscussionManager group to portal_groups with DiscussionManager role.\n") 80 82 81 83 out.write('Installation successfully completed.\n') … … 86 88 if not pp_ps.hasProperty(id): 87 89 pp_ps.manage_addProperty(id, value, property_type) 88 out.write("Adding %s property to %s property sheet\n" % (id, PROPERTY_SHEET) )90 out.write("Adding %s property to %s property sheet\n" % (id, 'qPloneComments') ) 89 91 90 92 … … 104 106 # Remove Product's property sheet from portal_properties 105 107 pp = getToolByName(self, 'portal_properties') 106 if PROPERTY_SHEETin pp.objectIds():107 pp.manage_delObjects(ids=[ PROPERTY_SHEET,])108 if 'qPloneComments' in pp.objectIds(): 109 pp.manage_delObjects(ids=['qPloneComments',]) qPloneComments/trunk/config.py
r241 r242 4 4 SKINS_DIR = "skins" 5 5 SKIN_NAME = "qplonecomments" 6 PROPERTY_SHEET = "qPloneComments"7 6 8 7 CONFIGLET_ID = "prefs_comments_setup_form" qPloneComments/trunk/patch.py
r241 r242 4 4 from Products.CMFCore.utils import getToolByName 5 5 6 #from config import *7 6 from utils import * 8 7 … … 34 33 else: 35 34 item.manage_addProperty(id='isAnon', value=value, type='boolean') 35 36 36 item.review_state="private" 37 37 38 item.__of__( self ).indexObject()39 40 38 item.setReplyTo( self._getDiscussable() ) 41 42 39 self._container[ id ] = item 43 40 44 41 # Control of performing moderation 45 ifModerate = getProp(self, " Enable_Moderation", marker=False)42 ifModerate = getProp(self, "enable_moderation", marker=False) 46 43 if ifModerate: 47 44 roles = ['DiscussionManager'] 48 45 item.manage_permission('Delete objects', roles, acquire=1) 49 #item.manage_permission('Review portal content', roles, acquire=0)50 46 item.manage_permission('View', roles, acquire=0) 51 47 else: 52 48 item.review_state = "published" 53 49 item._p_changed = 1 54 50 51 item.__of__( self ).indexObject() 55 52 return id 56 53 qPloneComments/trunk/skins/qplonecomments/discussion_publish_comment.py
r241 r242 9 9 ## 10 10 from Products.CMFPlone import transaction_note 11 from Products.CMFCore.utils import getToolByName 11 12 from Products.qPloneComments.utils import publishDiscussion, send_email 12 13 … … 16 17 parent = obj.inReplyTo() 17 18 if parent is not None: 18 talkback = context.portal_discussion.getDiscussionFor(parent) 19 dtool = getToolByName(context, 'portal_discussion') 20 talkback = dtool.getDiscussionFor(parent) 19 21 else: 20 22 talkback = parent = obj.aq_parent qPloneComments/trunk/skins/qplonecomments/discussion_reply.cpy
r241 r242 7 7 ##bind subpath=traverse_subpath 8 8 ##parameters=subject,body_text,text_format='plain',username=None,password=None 9 ##title=Reply to content 10 9 11 from Products.PythonScripts.standard import url_quote_plus 12 from Products.CMFCore.utils import getToolByName 10 13 from Products.qPloneComments.utils import send_email 11 from Products.CMFCore.utils import getToolByName12 from Products.qPloneComments.config import PROPERTY_SHEET13 14 15 mtool = getToolByName(context, 'portal_membership') 16 dtool = getToolByName(context, 'portal_discussion') 14 17 req = context.REQUEST 15 18 pp = getToolByName(context,'portal_properties') 16 mtool = getToolByName(context, 'portal_membership') 17 dtool = getToolByName(context, 'portal_discussion') 18 isForAnonymous = pp[PROPERTY_SHEET].getProperty('Enable_Anonymous_Commenting', None) 19 ifModerate = pp[PROPERTY_SHEET].getProperty('Enable_Moderation', None); 19 # Get properties 20 isForAnonymous = pp['qPloneComments'].getProperty('enable_anonymous_commenting', None) 21 ifModerate = pp['qPloneComments'].getProperty('enable_moderation', None); 20 22 21 23 if username or password: … … 53 55 comment_creator = comment_creator 54 56 else: 55 member = context.portal_membership.getAuthenticatedMember()57 member = mtool.getAuthenticatedMember() 56 58 # Get Member Full name.If not entered - get user login name 57 59 comment_creator = member.getProperty('fullname') … … 63 65 reply = tb.getReply(id) 64 66 65 # XXXTHIS NEEDS TO GO AWAY!67 # TODO THIS NEEDS TO GO AWAY! 66 68 if hasattr(dtool.aq_explicit, 'cookReply'): 67 69 dtool.cookReply(reply, text_format='plain') 68 70 69 71 parent = tb.aq_parent 70 71 from Products.CMFPlone import transaction_note72 transaction_note('Added comment to %s at %s' % (parent.title_or_id(), reply.absolute_url()))73 74 target = '%s/%s' % (parent.absolute_url(), parent.getTypeInfo().getActionById('view'))75 72 76 73 # Send notification e-mail … … 79 76 send_notification_message += send_email(reply, context, state="published") 80 77 78 from Products.CMFPlone import transaction_note 79 transaction_note('Added comment to %s at %s' % (parent.title_or_id(), reply.absolute_url())) 80 81 portal_status_message='Comment successfully added.' 82 81 83 # Inform user about awaiting moderation 82 portal_status_message='Comment successfully added.'83 84 if ifModerate and reply: 84 85 portal_status_message='Your comment awaits moderartion.' 85 86 86 return state.set(portal_status_message=portal_status_message) 87 target = '%s/%s?portal_status_message=%s' % (parent.absolute_url(), parent.getTypeInfo().getActionById('view'), portal_status_message) 88 89 return req.RESPONSE.redirect(target) qPloneComments/trunk/skins/qplonecomments/discussion_reply_form.cpt
r241 r242 21 21 action="talkback" 22 22 tal:attributes="action string:${here/getId}/${template/getId}" 23 tal:define="isForAnonymous python:here.portal_properties.qPloneComments.getProperty(' Enable_Anonymous_Commenting', 0)">23 tal:define="isForAnonymous python:here.portal_properties.qPloneComments.getProperty('enable_anonymous_commenting', 0)"> 24 24 <fieldset> 25 25 <legend i18n:translate="legend_comment_details">Comment Details</legend> 26 26 27 27 <input type="hidden" name="Creator" value="" 28 tal:attributes="value member/getUserName" 28 tal:attributes="value member/getUserName" 29 29 tal:condition="not:isForAnonymous" /> 30 30 … … 45 45 <div class="formHelp" i18n:translate="help_name" 46 46 tal:condition="isAnon"> 47 Enter your name for sign comment.47 Please tell us your name. 48 48 </div> 49 49 qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy
r241 r242 8 8 ##title= 9 9 ## 10 from Products. qPloneComments.config import PROPERTY_SHEET10 from Products.CMFCore.utils import getToolByName 11 11 from Products.qPloneComments.utils import setAnonymCommenting 12 from Products.CMFCore.utils import getToolByName13 12 14 13 form = context.REQUEST.form 15 14 pp = getToolByName(context, 'portal_properties') 16 props_sheet = getattr(pp, PROPERTY_SHEET)15 props_sheet = getattr(pp, 'qPloneComments') 17 16 property_maps=[(m['id'], m['type']) for m in props_sheet.propertyMap() if not m['id']=='title'] 18 17 request_ids = form.keys() … … 25 24 else: 26 25 kw[id] = False 27 if id == 'Enable_Anonymous_Commenting': 26 27 # Switch anonymouse commenting 28 if id == 'enable_anonymous_commenting': 28 29 allow = False 29 30 if id in request_ids: qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup_form.cpt
r241 r242 11 11 12 12 <div metal:define-macro="main" i18n:domain="plone"> 13 <div class="configlet"> 14 <div class="documentEditable"> 13 15 16 <!-- simulating views --> 17 <ul class="contentViews" 18 tal:define="tabs python:('Configure qPloneComments','prefs_comments_setup_form'), ('Recent comments moderation','prefs_recent_comments_form'),; 19 tabs python:[ {'label':label, 'name':name} for (label,name) in tabs ];" 20 > 21 <li class="selected" 22 tal:repeat="tab tabs" 23 tal:attributes="class python:tab['name']==template.id and 'selected' or ''"> 24 <a href="" 25 tal:attributes="href string:${here/absolute_url}/${tab/name}" 26 i18n:translate="" tal:content="tab/label">Configure qPloneComments</a> 27 </li> 28 </ul> 29 30 <div class="contentActions"> 31 32 </div> 33 <!-- End of tabs --> 34 <div class="documentContent" metal:define-slot="prefs_content"> 14 35 <h1 i18n:translate="qpc_setup">qPloneComments Setup</h1> 15 36 … … 26 47 enctype="multipart/form-data" 27 48 tal:define ="pp here/portal_properties; 28 ps_name python:modules['Products.qPloneComments.config'].PROPERTY_SHEET; 29 props_sheet python:getattr(pp, ps_name);" 49 props_sheet python:getattr(pp, 'qPloneComments');" 30 50 tal:attributes="action string:${here/getId}/${template/getId}"> 31 51 … … 34 54 35 55 <div class="field" 36 tal:define="property_id string: Enable_Moderation;56 tal:define="property_id string:enable_moderation; 37 57 isEnabledModeration python:props_sheet.getProperty(property_id, False);" 38 58 tal:condition="python:props_sheet.hasProperty(property_id)"> … … 54 74 55 75 <div class="field" 56 tal:define="property_id string: Enable_Anonymous_Commenting;76 tal:define="property_id string:enable_anonymous_commenting; 57 77 isEnabledAnonymousCommenting python:props_sheet.getProperty(property_id, False);" 58 78 tal:condition="python:props_sheet.hasProperty(property_id)"> … … 74 94 75 95 <div class="field" 76 tal:define="property_id string: Enable_Published_Notification;96 tal:define="property_id string:enable_published_notification; 77 97 isEnabledPublishedNotification python:props_sheet.getProperty(property_id, False);" 78 98 tal:condition="python:props_sheet.hasProperty(property_id)"> … … 93 113 94 114 <div class="field" 95 tal:define="property_id string: Enable_Approve_Notification;115 tal:define="property_id string:enable_approve_notification; 96 116 isEnableApproveNotification python:props_sheet.getProperty(property_id, False);" 97 117 tal:condition="python:props_sheet.hasProperty(property_id)"> … … 111 131 </div> 112 132 113 <!-- <fieldset> 114 <legend i18n:translate="legend_qpc_setup_legend">Notification and e-mail</legend> 115 --> 116 <div class="field" 117 tal:define="property_id string:Email_Discussion_Manager; 118 email python:props_sheet.getProperty(property_id, ''); 119 error python:test(errors.has_key(property_id), errors.get(property_id), None);" 120 tal:attributes="class python:test(error, 'field error', 'field')" 121 tal:condition="python:props_sheet.hasProperty(property_id)"> 122 123 <label i18n:translate="label_discussion-manager_email">Send comments notification emails to:</label> 124 125 <div class="formHelp" id="smtp_server_help" 126 i18n:translate="help_discussion-manager_email"> 127 The e-mail address where notifications about adding new comments will be sent. 128 </div> 129 130 <div tal:content="error">Validation error output</div> 133 <div class="field" 134 tal:define="property_id string:email_discussion_manager; 135 email python:props_sheet.getProperty(property_id, ''); 136 error python:test(errors.has_key(property_id), errors.get(property_id), None);" 137 tal:attributes="class python:test(error, 'field error', 'field')" 138 tal:condition="python:props_sheet.hasProperty(property_id)"> 139 140 <label i18n:translate="label_discussion-manager_email">Send comments notification emails to:</label> 141 142 <div class="formHelp" id="smtp_server_help" 143 i18n:translate="help_discussion-manager_email"> 144 The e-mail address where notifications about adding new comments will be sent. 145 </div> 146 147 <div tal:content="error">Validation error output</div> 131 148 132 <input name="email_discussion-manager" 133 value="" 134 size="40" 135 tabindex="" 136 tal:attributes="name property_id; 137 value email; 138 tabindex tabindex/next;" /> 149 <input name="email_discussion-manager" 150 value="" 151 size="40" 152 tabindex="" 153 tal:attributes="name property_id; 154 value email; 155 tabindex tabindex/next;" /> 156 </div> 157 158 <div class="field" 159 tal:define="property_id string:email_subject_prefix; 160 organization_name python:props_sheet.getProperty(property_id, '');" 161 tal:condition="python:props_sheet.hasProperty(property_id)"> 162 163 <label i18n:translate="label_organization_name">Email subject prefix (organization name)</label> 164 165 <div class="formHelp" id="organization_name_help" 166 i18n:translate="help_organization_name"> 167 You can change notification message templates customizing 'approve_comment_template' and 'published_comment_template' from qplonecomments skin. 139 168 </div> 140 141 <div class="field" 142 tal:define="property_id string:Email_Subject_Prefix; 143 organization_name python:props_sheet.getProperty(property_id, '');" 144 tal:condition="python:props_sheet.hasProperty(property_id)"> 145 146 <label i18n:translate="label_organization_name">Email subject prefix (organization name)</label> 147 148 <div class="formHelp" id="organization_name_help" 149 i18n:translate="help_organization_name"> 150 You can change notification message templates customizing 'approve_comment_template' 151 and 'published_comment_template' from qplonecomments skin. 152 </div> 153 154 <input name="organization_name" 155 value="" 156 size="40" 157 tabindex="" 158 tal:attributes="name property_id; 159 value organization_name; 160 tabindex tabindex/next;" /> 161 </div> 162 <!--</fieldset> 163 --> 169 170 <input name="organization_name" 171 value="" 172 size="40" 173 tabindex="" 174 tal:attributes="name property_id; 175 value organization_name; 176 tabindex tabindex/next;" /> 177 </div> 164 178 165 179 <div class="formControls"> … … 178 192 </form> 179 193 </div> 180 194 </div> 195 </div> 196 </div> 181 197 </div> 182 183 198 </body> 184 185 199 </html> qPloneComments/trunk/skins/qplonecomments/validate_setup.vpy
r241 r242 8 8 ##parameters= 9 9 ##title=validates qpc setup 10 10 ## 11 11 from Products.CMFCore.utils import getToolByName 12 12 13 13 form = context.REQUEST.form 14 email_key = ' Email_Discussion_Manager'14 email_key = 'email_discussion_manager' 15 15 16 16 if email_key in form: qPloneComments/trunk/skins/qplonecomments/validate_talkback.vpy
r241 r242 8 8 ##parameters=subject='',body_text='' 9 9 ##title=validates a discussion entry 10 10 ## 11 11 from Products.CMFCore.utils import getToolByName 12 from Products.qPloneComments.config import PROPERTY_SHEET13 12 14 13 if not subject: … … 19 18 20 19 pp = getToolByName(context, 'portal_properties') 21 isForAnonymous = pp[ PROPERTY_SHEET].getProperty('Enable_Anonymous_Commenting', None)20 isForAnonymous = pp['qPloneComments'].getProperty('enable_anonymous_commenting', None) 22 21 if isForAnonymous: 23 22 pm = getToolByName(context, 'portal_membership') qPloneComments/trunk/skins/qplonecomments/viewThreadsAtBottom.pt
r241 r242 9 9 portal_discussion portal/portal_discussion; 10 10 isDiscussionAllowed python:portal_discussion.isDiscussionAllowedFor(here); 11 userIsAnonymous isAnon;12 11 hereTypeInfo python:request.get('this_typeinfo', here.getTypeInfo()); 13 12 view_action python:hereTypeInfo.getActionById('view'); … … 30 29 </form> 31 30 32 <form tal:condition="python: userIsAnonymousand not userHasReplyPermission"31 <form tal:condition="python:isAnon and not userHasReplyPermission" 33 32 tal:define="pss modules/Products/PythonScripts/standard" 34 33 tal:attributes="action python:'%s/login_form?came_from=%s' % … … 50 49 <div class="comment" 51 50 tal:define="isPublished python:reply.review_state=='published'; 52 ifModerate python:here.portal_properties.qPloneComments.getProperty(' Enable_Moderation', None);">51 ifModerate python:here.portal_properties.qPloneComments.getProperty('enable_moderation', None);"> 53 52 <h3> 54 53 <tal:block replace="structure portal/discussionitem_icon.gif"/> qPloneComments/trunk/tests/testQPloneCommentsCommenting.py
r241 r242 166 166 pp = getToolByName(self.portal, 'portal_properties') 167 167 config_ps = getattr(pp, 'qPloneComments', None) 168 EnableAnonymComm = getattr(config_ps, " Enable_Anonymous_Commenting")168 EnableAnonymComm = getattr(config_ps, "enable_anonymous_commenting") 169 169 # Group users depending on Anonymous commenting enabling/disabling 170 170 if EnableAnonymComm: … … 277 277 pp = getToolByName(self.portal, 'portal_properties') 278 278 config_ps = getattr(pp, 'qPloneComments', None) 279 EnableAnonymComm = getattr(config_ps, " Enable_Anonymous_Commenting")279 EnableAnonymComm = getattr(config_ps, "enable_anonymous_commenting") 280 280 # Group users depending on Anonymous commenting enabling/disabling 281 281 if EnableAnonymComm: … … 344 344 # Preparation for functional testing 345 345 # Tern On Moderation and tern on Anonymous commenting 346 self.request.form[' Enable_Anonymous_Commenting'] = 'True'347 self.request.form[' Enable_Moderation'] = 'True'346 self.request.form['enable_anonymous_commenting'] = 'True' 347 self.request.form['enable_moderation'] = 'True' 348 348 self.portal.prefs_comments_setup() 349 349 # Initialize base classes … … 358 358 # Preparation for functional testing 359 359 # Tern On Moderation and tern off Anonymous commenting 360 self.request.form[' Enable_Moderation'] = 'True'360 self.request.form['enable_moderation'] = 'True' 361 361 self.portal.prefs_comments_setup() 362 362 # Initialize base classes … … 372 372 # Preparation for functional testing 373 373 # Tern On Anonymous commenting and tern off Moderation 374 self.request.form[' Enable_Anonymous_Commenting'] = 'True'374 self.request.form['enable_anonymous_commenting'] = 'True' 375 375 self.portal.prefs_comments_setup() 376 376 # Initialize base classes qPloneComments/trunk/tests/testQPloneCommentsConfiglet.py
r241 r242 75 75 self.login('dm') 76 76 # For prepare mail sending - enter an e-mail adress 77 self.prefs._updateProperty(' Email_Discussion_Manager', 'discussion.manager@test.com')77 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 78 78 member = self.portal.portal_membership.getAuthenticatedMember() 79 79 member.setMemberProperties({'email':'creator@test.com'}) … … 91 91 return [r['name'] for r in getPortalReplyPerm(ReplyToItem) if r['selected']=='SELECTED'] 92 92 # Simulate switching ON Anonymous Commenting 93 self.request.form[' Enable_Anonymous_Commenting'] = 'True'93 self.request.form['enable_anonymous_commenting'] = 'True' 94 94 self.portal.prefs_comments_setup() 95 95 actual_reply_permission = getReplyRoles() … … 97 97 "'Reply to Item' permission set for %s. 'Anonymous' role NOT added" % actual_reply_permission) 98 98 # Simulate switching OFF Anonymous Commenting 99 if self.request.form.has_key(' Enable_Anonymous_Commenting'):100 del self.request.form[' Enable_Anonymous_Commenting']99 if self.request.form.has_key('enable_anonymous_commenting'): 100 del self.request.form['enable_anonymous_commenting'] 101 101 self.portal.prefs_comments_setup() 102 102 actual_reply_permission = getReplyRoles() … … 108 108 addUsers(self) 109 109 self.discussion = self.portal.portal_discussion 110 self.request.form[' Enable_Anonymous_Commenting'] = 'True'111 self.request.form[' Enable_Moderation'] = 'True'110 self.request.form['enable_anonymous_commenting'] = 'True' 111 self.request.form['enable_moderation'] = 'True' 112 112 self.portal.prefs_comments_setup() 113 113 # Create talkback for document and Add comment to my_doc … … 132 132 addUsers(self) 133 133 self.discussion = self.portal.portal_discussion 134 self.request.form[' Enable_Anonymous_Commenting'] = 'True'134 self.request.form['enable_anonymous_commenting'] = 'True' 135 135 self.portal.prefs_comments_setup() 136 136 # Create talkback for document and Add comment to my_doc … … 153 153 def testApproveNotification(self): 154 154 # Check ON Notification Anonymous Commenting 155 self.request.form[' Enable_Approve_Notification'] = 'True'155 self.request.form['enable_approve_notification'] = 'True' 156 156 self.portal.prefs_comments_setup() 157 self.assert_(self.prefs.getProperty(' Enable_Approve_Notification')==1,"Approve Notification not terned ON")157 self.assert_(self.prefs.getProperty('enable_approve_notification')==1,"Approve Notification not terned ON") 158 158 159 159 # Check OFF Notification Anonymous Commenting 160 if self.request.form.has_key(' Enable_Approve_Notification'):161 del self.request.form[' Enable_Approve_Notification']160 if self.request.form.has_key('enable_approve_notification'): 161 del self.request.form['enable_approve_notification'] 162 162 self.portal.prefs_comments_setup() 163 self.assert_(self.prefs.getProperty(' Enable_Approve_Notification')==0,"Approve Notification not terned OFF")163 self.assert_(self.prefs.getProperty('enable_approve_notification')==0,"Approve Notification not terned OFF") 164 164 165 165 166 166 def testPublishedNotification(self): 167 167 # Check ON Notification Anonymous Commenting 168 self.request.form[' Enable_Published_Notification'] = 'True'168 self.request.form['enable_published_notification'] = 'True' 169 169 self.portal.prefs_comments_setup() 170 self.assert_(self.prefs.getProperty(' Enable_Published_Notification')==1,"Published Notification not terned ON")170 self.assert_(self.prefs.getProperty('enable_published_notification')==1,"Published Notification not terned ON") 171 171 172 172 # Check OFF Notification Anonymous Commenting 173 if self.request.form.has_key(' Enable_Published_Notification'):174 del self.request.form[' Enable_Published_Notification']173 if self.request.form.has_key('enable_published_notification'): 174 del self.request.form['enable_published_notification'] 175 175 self.portal.prefs_comments_setup() 176 self.assert_(self.prefs.getProperty(' Enable_Published_Notification')==0,"Published Notification not terned OFF")176 self.assert_(self.prefs.getProperty('enable_published_notification')==0,"Published Notification not terned OFF") 177 177 178 178 qPloneComments/trunk/tests/testQPloneCommentsInstall.py
r241 r242 16 16 CONFIGLET_ID = "prefs_comments_setup_form" 17 17 18 EMAIL_PID = " Email_Discussion_Manager"19 APPROVE_NOTIFICATION_PID = " Enable_Approve_Notification"20 PUBLISHED_NOTIFICATION_PID = " Enable_Published_Notification"21 MODERATION_PID = " Enable_Moderation"22 ANONYMOUS_COMMENTING_PID = " Enable_Anonymous_Commenting"18 EMAIL_PID = "email_discussion_manager" 19 APPROVE_NOTIFICATION_PID = "enable_approve_notification" 20 PUBLISHED_NOTIFICATION_PID = "enable_published_notification" 21 MODERATION_PID = "enable_moderation" 22 ANONYMOUS_COMMENTING_PID = "enable_anonymous_commenting" 23 23 24 24 PloneTestCase.installProduct(PRODUCT) qPloneComments/trunk/tests/testQPloneCommentsNotification.py
r241 r242 24 24 25 25 def setApprovePublished(self, swithA=1,swithP=1): 26 self.prefs._updateProperty(' Enable_Approve_Notification', swithA)27 self.prefs._updateProperty(' Enable_Published_Notification', swithP)26 self.prefs._updateProperty('enable_approve_notification', swithA) 27 self.prefs._updateProperty('enable_published_notification', swithP) 28 28 29 29 … … 54 54 self.login('dm') 55 55 # For prepare mail sending - enter an e-mail adress 56 self.prefs._updateProperty(' Email_Discussion_Manager', 'discussion.manager@test.com')56 self.prefs._updateProperty('email_discussion_manager', 'discussion.manager@test.com') 57 57 member = self.portal.portal_membership.getAuthenticatedMember() 58 58 member.setMemberProperties({'email':'creator@test.com'}) … … 108 108 109 109 def testOFFModerationApprovePublished(self): 110 self.prefs._updateProperty(' Enable_Moderation', 0)110 self.prefs._updateProperty('enable_moderation', 0) 111 111 112 112 # Test Enable Approve Notification & Enable Published Notification … … 118 118 119 119 def testOFFModerationApprove(self): 120 self.prefs._updateProperty(' Enable_Moderation', 0)120 self.prefs._updateProperty('enable_moderation', 0) 121 121 122 122 # Test Enable Approve Notification & Disable Published Notification … … 128 128 129 129 def testOFFModerationPublished(self): 130 self.prefs._updateProperty(' Enable_Moderation', 0)130 self.prefs._updateProperty('enable_moderation', 0) 131 131 132 132 # Test Enable Published Notification & Disable Approve Notification … … 138 138 139 139 def testOFFModeration(self): 140 self.prefs._updateProperty(' Enable_Moderation', 0)140 self.prefs._updateProperty('enable_moderation', 0) 141 141 142 142 # Test Disable Published Notification & Disable Approve Notification qPloneComments/trunk/utils.py
r241 r242 1 1 from Products.CMFCore.utils import getToolByName 2 from config import *3 2 4 3 # Get apropriate property from (propery_sheeet) configlet … … 6 5 result = marker 7 6 pp = getToolByName(self, 'portal_properties') 8 config_ps = getattr(pp, PROPERTY_SHEET, None)7 config_ps = getattr(pp, 'qPloneComments', None) 9 8 if config_ps: 10 9 result = getattr(config_ps, prop_name, marker) … … 12 11 13 12 14 # Send notification e-mail on 13 # Send notification e-mail on Discussion_Reply 15 14 # Possible values for state: ["approve", "published"] 16 15 def send_email(reply, context, state="approve"): … … 18 17 notify = False 19 18 if state=="approve": 20 notify = getProp(context, " Enable_Approve_Notification", False)19 notify = getProp(context, "enable_approve_notification", False) 21 20 elif state=="published": 22 notify = getProp(context, " Enable_Published_Notification", False)21 notify = getProp(context, "enable_published_notification", False) 23 22 if not notify: 24 23 return 0 … … 37 36 portal = getToolByName(context, 'portal_url').getPortalObject() 38 37 from_address = portal.getProperty('email_from_address') 39 38 40 39 # Get email address based on state 41 40 to_address = None … … 48 47 to_address = creator.getProperty('email', None) 49 48 elif state=="approve": 50 to_address = getProp(context, " Email_Discussion_Manager", None)49 to_address = getProp(context, "email_discussion_manager", None) 51 50 52 51 # Combine and send email … … 57 56 template = getattr(context, 'approve_comment_template') 58 57 59 organization_name = getProp(context, " Email_Subject_Prefix", "")58 organization_name = getProp(context, "email_subject_prefix", "") 60 59 message = template(obj=parent, mto=to_address, 61 60 mfrom=from_address, organization_name=organization_name) … … 73 72 self.manage_permission('View', roles, acquire=1) 74 73 self._p_changed = 1 74 self.reindexObject() 75 75 76 76 … … 82 82 portal.manage_permission('Reply to item', ['Manager','Member'], 1) 83 83 84 84
