Changeset 149
- Timestamp:
- 01/04/06 13:27:27
- Files:
-
- qPloneComments/trunk/Extensions/Install.py (modified) (1 diff)
- qPloneComments/trunk/patch.py (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/comment_template.pt (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/ifModerate.py (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/isForAnonymous.py (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/prefs_qpc_setup.cpy (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/prefs_qpc_setup_form.cpt (modified) (3 diffs)
- qPloneComments/trunk/skins/qplonecomments/validate_setup.vpy (modified) (1 diff)
- qPloneComments/trunk/tests/testQPloneComments.py (modified) (7 diffs)
- qPloneComments/trunk/utils.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/trunk/Extensions/Install.py
r148 r149 49 49 out.write("Adding %s property sheet to portal_properies\n" % PROPERTY_SHEET ) 50 50 props_sheet = pp[PROPERTY_SHEET] 51 updateProperty(props_sheet, id="Email_of_discussion_manager", value="", property_type='string', out=out) 52 updateProperty(props_sheet, id="Turning_on/off_notification", value="True", property_type='boolean', out=out) 53 updateProperty(props_sheet, id="Turning_on/off_Moderation", value="True", property_type='boolean', out=out) 54 updateProperty(props_sheet, id="Turning_on/off_Anonymous_Commenting", value="True", property_type='boolean', out=out) 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_Notification", value="True", property_type='boolean', out=out) 54 updateProperty(props_sheet, id="Email_Discussion_Manager", value="", property_type='string', out=out) 55 updateProperty(props_sheet, id="Email_Subject_Prefix", value="", property_type='string', out=out) 56 55 57 out.write("Updating properties of %s property sheet\n" % PROPERTY_SHEET ) 56 58 qPloneComments/trunk/patch.py
r148 r149 43 43 44 44 # Control of performing moderation 45 ifModerate = getProp(self, " Turning_on/off_Moderation", marker=False)45 ifModerate = getProp(self, "Enable_Moderation", marker=False) 46 46 if ifModerate: 47 47 from zLOG import LOG qPloneComments/trunk/skins/qplonecomments/comment_template.pt
r148 r149 9 9 10 10 -- 11 Support Team. 11 <tal:x replace="options/mbsign"/> qPloneComments/trunk/skins/qplonecomments/ifModerate.py
r148 r149 10 10 from Products.qPloneComments.utils import getProp 11 11 12 return getProp(context, " Turning_on/off_Moderation", False)12 return getProp(context, "Enable_Moderation", False) qPloneComments/trunk/skins/qplonecomments/isForAnonymous.py
r148 r149 10 10 from Products.qPloneComments.utils import getProp 11 11 12 return getProp(context, " Turning_on/off_Anonymous_Commenting", False)12 return getProp(context, "Enable_Anonymous_Commenting", False) qPloneComments/trunk/skins/qplonecomments/prefs_qpc_setup.cpy
r148 r149 28 28 29 29 # Switch anonymouse commenting 30 if id == ' Turning_on/off_Anonymous_Commenting':30 if id == 'Enable_Anonymous_Commenting': 31 31 allow = False 32 32 if id in request_ids: qPloneComments/trunk/skins/qplonecomments/prefs_qpc_setup_form.cpt
r148 r149 31 31 32 32 <fieldset> 33 <legend i18n:translate="legend_ mailhost_details">qPloneComments setup Details</legend>33 <legend i18n:translate="legend_qpc_notification_legend">qPloneComments setup Details</legend> 34 34 35 35 <div class="field" 36 tal:define="property_id string:Email_of_discussion_manager; 37 email python:props_sheet.getProperty(property_id, ''); 38 error python:test(errors.has_key(property_id), errors.get(property_id), None);" 39 tal:attributes="class python:test(error, 'field error', 'field')" 40 tal:condition="python:props_sheet.hasProperty(property_id)"> 41 42 <label i18n:translate="label_discussion-manager_email">E-mail of discussion manager</label> 43 44 <div class="formHelp" id="smtp_server_help" 45 i18n:translate="help_discussion-manager_email"> 46 The e-mail address where notifications about adding new comments will be sent. 47 </div> 48 49 <div tal:content="error">Validation error output</div> 50 51 <input name="email_discussion-manager" 52 value="" 53 size="40" 54 tabindex="" 55 tal:attributes="name property_id; 56 value email; 57 tabindex tabindex/next;" /> 58 </div> 59 60 <div class="field" 61 tal:define="property_id string:Turning_on/off_notification; 62 isEnabledNotification python:props_sheet.getProperty(property_id, False);" 63 tal:condition="python:props_sheet.hasProperty(property_id)"> 64 65 <input type="checkbox" 66 class="noborder" 67 name="isEnabledNotification" 68 id="isEnabledNotification" 69 tabindex ="" 70 tal:attributes="name property_id; 71 value isEnabledNotification; 72 checked python:test(isEnabledNotification, 'True', ''); 73 tabindex tabindex/next;"/> 74 75 <label i18n:translate="label_enable_notification" 76 for="isEnabledNotification">Enable e-mail notification about comments adding.</label> 77 78 <div class="formHelp" i18n:translate="help_enable_notification"> 79 If checked, notification will be sent to discussion manager's e-mail. 80 </div> 81 </div> 82 83 <div class="field" 84 tal:define="property_id string:Turning_on/off_Moderation; 36 tal:define="property_id string:Enable_Moderation; 85 37 isEnabledModeration python:props_sheet.getProperty(property_id, False);" 86 38 tal:condition="python:props_sheet.hasProperty(property_id)"> … … 99 51 for="isEnabledModeration">Enable moderation.</label> 100 52 101 <div class="formHelp" i18n:translate="help_enable_moderation">102 If checked, moderation for new comments will be activated.103 </div>104 53 </div> 105 54 106 55 <div class="field" 107 tal:define="property_id string: Turning_on/off_Anonymous_Commenting;56 tal:define="property_id string:Enable_Anonymous_Commenting; 108 57 isEnabledAnonymousCommenting python:props_sheet.getProperty(property_id, False);" 109 58 tal:condition="python:props_sheet.hasProperty(property_id)"> … … 120 69 121 70 <label i18n:translate="label_anonymous_commenting" 122 for="isEnabledAnonymousCommenting">Enable commenting for anonymous users.</label>71 for="isEnabledAnonymousCommenting">Enable anonymous comenting.</label> 123 72 124 <div class="formHelp" i18n:translate="help_anonymous_commenting"> 125 If checked, anonymous users will be able to add comments and sign them. 73 </div> 74 75 <div class="field" 76 tal:define="property_id string:Enable_Notification; 77 isEnabledNotification python:props_sheet.getProperty(property_id, False);" 78 tal:condition="python:props_sheet.hasProperty(property_id)"> 79 80 <input type="checkbox" 81 class="noborder" 82 name="isEnabledNotification" 83 id="isEnabledNotification" 84 tabindex ="" 85 tal:attributes="name property_id; 86 value isEnabledNotification; 87 checked python:test(isEnabledNotification, 'True', ''); 88 tabindex tabindex/next;"/> 89 90 <label i18n:translate="label_enable_notification" 91 for="isEnabledNotification">Enable e-mail notification on new coments.</label> 92 </div> 93 94 <!-- <fieldset> 95 <legend i18n:translate="legend_qpc_setup_legend">Notification and e-mail</legend> 96 --> 97 <div class="field" 98 tal:define="property_id string:Email_Discussion_Manager; 99 email python:props_sheet.getProperty(property_id, ''); 100 error python:test(errors.has_key(property_id), errors.get(property_id), None);" 101 tal:attributes="class python:test(error, 'field error', 'field')" 102 tal:condition="python:props_sheet.hasProperty(property_id)"> 103 104 <label i18n:translate="label_discussion-manager_email">Send comments notification emails to:</label> 105 106 <div class="formHelp" id="smtp_server_help" 107 i18n:translate="help_discussion-manager_email"> 108 The e-mail address where notifications about adding new comments will be sent. 109 </div> 110 111 <div tal:content="error">Validation error output</div> 112 113 <input name="email_discussion-manager" 114 value="" 115 size="40" 116 tabindex="" 117 tal:attributes="name property_id; 118 value email; 119 tabindex tabindex/next;" /> 126 120 </div> 127 </div> 121 122 <div class="field" 123 tal:define="property_id string:Email_Subject_Prefix; 124 organization_name python:props_sheet.getProperty(property_id, '');" 125 tal:condition="python:props_sheet.hasProperty(property_id)"> 126 127 <label i18n:translate="label_organization_name">Email subject prefix (organization name)</label> 128 129 <div class="formHelp" id="organization_name_help" 130 i18n:translate="help_organization_name"> 131 You can overide message template with custom your 'comment_template' pagetemplate. 132 </div> 133 134 <input name="organization_name" 135 value="" 136 size="40" 137 tabindex="" 138 tal:attributes="name property_id; 139 value organization_name; 140 tabindex tabindex/next;" /> 141 </div> 142 <!--</fieldset> 143 --> 128 144 129 145 <div class="formControls"> qPloneComments/trunk/skins/qplonecomments/validate_setup.vpy
r148 r149 12 12 13 13 form = context.REQUEST.form 14 email_key = 'Email_ of_discussion_manager'14 email_key = 'Email_Discussion_Manager' 15 15 16 16 if email_key in form: qPloneComments/trunk/tests/testQPloneComments.py
r148 r149 32 32 #CONFIGLET_NAME = "qPloneComments config" 33 33 34 EMAIL_PID = "Email_ of_discussion_manager"35 NOTIFICATION_PID = " Turning_on/off_notification"36 MODERATION_PID = " Turning_on/off_Moderation"37 ANONYMOUS_COMMENTING_PID = " Turning_on/off_Anonymous_Commenting"34 EMAIL_PID = "Email_Discussion_Manager" 35 NOTIFICATION_PID = "Enable_Notification" 36 MODERATION_PID = "Enable_Moderation" 37 ANONYMOUS_COMMENTING_PID = "Enable_Anonymous_Commenting" 38 38 39 39 … … 162 162 return [r['name'] for r in getPortalReplyPerm(ReplyToItem) if r['selected']=='SELECTED'] 163 163 # Simulate switching ON Anonymous Commenting 164 self.request.form[' Turning_on/off_Anonymous_Commenting'] = 'True'164 self.request.form['Enable_Anonymous_Commenting'] = 'True' 165 165 self.portal.prefs_qpc_setup() 166 166 actual_reply_permission = getReplyRoles() … … 168 168 "'Reply to Item' permission set for %s. 'Anonymous' role NOT added" % actual_reply_permission) 169 169 # Simulate switching OFF Anonymous Commenting 170 if self.request.form.has_key(' Turning_on/off_Anonymous_Commenting'):171 del self.request.form[' Turning_on/off_Anonymous_Commenting']170 if self.request.form.has_key('Enable_Anonymous_Commenting'): 171 del self.request.form['Enable_Anonymous_Commenting'] 172 172 self.portal.prefs_qpc_setup() 173 173 actual_reply_permission = getReplyRoles() … … 178 178 def testSwitchONModeration(self): 179 179 self.discussion = self.portal.portal_discussion 180 self.request.form[' Turning_on/off_Anonymous_Commenting'] = 'True'181 self.request.form[' Turning_on/off_Moderation'] = 'True'180 self.request.form['Enable_Anonymous_Commenting'] = 'True' 181 self.request.form['Enable_Moderation'] = 'True' 182 182 self.portal.prefs_qpc_setup() 183 183 # Create talkback for document and Add comment to my_doc … … 202 202 def testSwitchOFFModeration(self): 203 203 self.discussion = self.portal.portal_discussion 204 self.request.form[' Turning_on/off_Anonymous_Commenting'] = 'True'204 self.request.form['Enable_Anonymous_Commenting'] = 'True' 205 205 self.portal.prefs_qpc_setup() 206 206 # Create talkback for document and Add comment to my_doc … … 223 223 def testNotification(self): 224 224 # For prepare mail sending - enter an e-mail adress 225 self.prefs._updateProperty('Email_ of_discussion_manager', 'wrong_email_addr')225 self.prefs._updateProperty('Email_Discussion_Manager', 'wrong_email_addr') 226 226 # Create talkback for document and Prepare REQUEST 227 227 self.portal.portal_discussion.getDiscussionFor(self.my_doc) … … 231 231 232 232 # Check Notification ON 233 self.assert_(self.prefs.getProperty(' Turning_on/off_notification')==1,"Notification not terned ON")233 self.assert_(self.prefs.getProperty('Enable_Notification')==1,"Notification not terned ON") 234 234 self.assertRaises(socket.error, self.my_doc.discussion_reply, 'Reply 1', 'text of reply') 235 235 # Check Notification OFF 236 self.prefs._updateProperty(' Turning_on/off_notification', 0)237 self.assert_(self.prefs.getProperty(' Turning_on/off_notification')==0,"Notification not terned Off")236 self.prefs._updateProperty('Enable_Notification', 0) 237 self.assert_(self.prefs.getProperty('Enable_Notification')==0,"Notification not terned Off") 238 238 try: 239 239 self.my_doc.discussion_reply('Reply 1','text of reply') qPloneComments/trunk/utils.py
r148 r149 27 27 def send_email(reply, context): 28 28 # Check is notification active 29 notify = getProp(context, " Turning_on/off_notification", False)29 notify = getProp(context, "Enable_Notification", False) 30 30 if not notify: 31 31 return … … 41 41 42 42 # Get discussion manager's email 43 admin_email = getProp(context, "Email_ of_discussion_manager", None)43 admin_email = getProp(context, "Email_Discussion_Manager", None) 44 44 45 45 # Set sending email to creator's or admin's one … … 57 57 # Combine and send email 58 58 if email: 59 organization_name = getProp(context, "Email_Subject_Prefix", "") 60 subject = "New comment added" 61 bottom_sign = "Support Team." 62 if organization_name: 63 subject = "[%s] %s" % (organization_name, subject) 64 bottom_sign = "%s %s" % (organization_name, bottom_sign) 65 59 66 body = context.comment_template(obj=parent, 60 67 mto=email, 61 msubject="[Cornicen] New comment added", 62 mfrom=admin_email) 68 msubject=subject, 69 mfrom=admin_email, 70 mbsign=bottom_sign) 63 71 mh = context.MailHost 64 72 mh.send(body)
