Changeset 208
- Timestamp:
- 01/25/06 11:29:26
- Files:
-
- qPloneComments/trunk/Extensions/Install.py (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/approve_comment_template.pt (added)
- qPloneComments/trunk/skins/qplonecomments/comment_template.pt (deleted)
- qPloneComments/trunk/skins/qplonecomments/discussion_reply.cpy (modified) (4 diffs)
- qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy (modified) (1 diff)
- qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup_form.cpt (modified) (2 diffs)
- qPloneComments/trunk/skins/qplonecomments/published_comment_template.pt (added)
- qPloneComments/trunk/tests/testQPloneCommentsInstall.py (modified) (2 diffs)
- qPloneComments/trunk/utils.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/trunk/Extensions/Install.py
r207 r208 51 51 updateProperty(props_sheet, id="Enable_Moderation", value="True", property_type='boolean', out=out) 52 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) 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) 54 55 updateProperty(props_sheet, id="Email_Discussion_Manager", value="", property_type='string', out=out) 55 56 updateProperty(props_sheet, id="Email_Subject_Prefix", value="", property_type='string', out=out) qPloneComments/trunk/skins/qplonecomments/discussion_reply.cpy
r207 r208 14 14 req = context.REQUEST 15 15 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); 16 20 17 21 if username or password: … … 44 48 ######################################################### 45 49 # Get discussion item (reply) author and creating reply # 46 isForAnonymous = pp[PROPERTY_SHEET].getProperty('Enable_Anonymous_Commenting', None)47 50 comment_creator = req.get('Creator', None) 48 51 if isForAnonymous and comment_creator: … … 61 64 62 65 #XXX THIS NEEDS TO GO AWAY! 63 portal_discussion=context.portal_discussion 64 if hasattr(portal_discussion.aq_explicit, 'cookReply'): 65 portal_discussion.cookReply(reply, text_format='plain') 66 if hasattr(dtool.aq_explicit, 'cookReply'): 67 dtool.cookReply(reply, text_format='plain') 66 68 67 69 parent = tb.aq_parent … … 73 75 74 76 # Send notification e-mail 75 send_email(reply, context) 77 send_notification_message = send_email(reply, context, state="approve") 78 if not ifModerate: 79 send_notification_message += send_email(reply, context, state="published") 76 80 77 81 # Inform user about awaiting moderation 78 82 portal_status_message='Comment successfully added.' 79 ifModerate = pp[PROPERTY_SHEET].getProperty('Enable_Moderation', None);80 83 if ifModerate and reply: 81 84 portal_status_message='Your comment awaits moderartion.' qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy
r207 r208 40 40 props_sheet.manage_changeProperties(kw) 41 41 42 return state.set(portal_status_message=' Documentchanges saved.')42 return state.set(portal_status_message='qPloneComments configuration changes saved.') qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup_form.cpt
r207 r208 74 74 75 75 <div class="field" 76 tal:define="property_id string:Enable_ Notification;77 isEnabled Notification python:props_sheet.getProperty(property_id, False);"76 tal:define="property_id string:Enable_Published_Notification; 77 isEnabledPublishedNotification python:props_sheet.getProperty(property_id, False);" 78 78 tal:condition="python:props_sheet.hasProperty(property_id)"> 79 79 80 80 <input type="checkbox" 81 81 class="noborder" 82 name="isEnabled Notification"83 id="isEnabled Notification"82 name="isEnabledPublishedNotification" 83 id="isEnabledPublishedNotification" 84 84 tabindex ="" 85 85 tal:attributes="name property_id; 86 value isEnabled Notification;87 checked python:test(isEnabled Notification, 'True', '');86 value isEnabledPublishedNotification; 87 checked python:test(isEnabledPublishedNotification, 'True', ''); 88 88 tabindex tabindex/next;"/> 89 89 90 <label i18n:translate="label_enable_notification" 91 for="isEnabledNotification">Enable e-mail notification on new coments.</label> 90 <label i18n:translate="label_enable_published_notification" 91 for="isEnabledPublishedNotification">Enable Document Owner notification on new comments.</label> 92 </div> 93 94 <div class="field" 95 tal:define="property_id string:Enable_Approve_Notification; 96 isEnableApproveNotification python:props_sheet.getProperty(property_id, False);" 97 tal:condition="python:props_sheet.hasProperty(property_id)"> 98 99 <input type="checkbox" 100 class="noborder" 101 name="isEnableApproveNotification" 102 id="isEnableApproveNotification" 103 tabindex ="" 104 tal:attributes="name property_id; 105 value isEnableApproveNotification; 106 checked python:test(isEnableApproveNotification, 'True', ''); 107 tabindex tabindex/next;"/> 108 109 <label i18n:translate="label_enable_approve_notification" 110 for="isEnableApproveNotification">Enable Discussion Manager notification on new comments.</label> 92 111 </div> 93 112 … … 129 148 <div class="formHelp" id="organization_name_help" 130 149 i18n:translate="help_organization_name"> 131 You can overide message template with custom your 'comment_template' pagetemplate. 150 You can change notification message templates customizing 'approve_comment_template' 151 and 'published_comment_template' from qplonecomments skin. 132 152 </div> 133 153 qPloneComments/trunk/tests/testQPloneCommentsInstall.py
r207 r208 17 17 18 18 EMAIL_PID = "Email_Discussion_Manager" 19 NOTIFICATION_PID = "Enable_Notification" 19 APPROVE_NOTIFICATION_PID = "Enable_Approve_Notification" 20 PUBLISHED_NOTIFICATION_PID = "Enable_Published_Notification" 20 21 MODERATION_PID = "Enable_Moderation" 21 22 ANONYMOUS_COMMENTING_PID = "Enable_Anonymous_Commenting" … … 62 63 property_ids = portal_properties[PROPERTY_SHEET].propertyIds() 63 64 self.assert_(EMAIL_PID in property_ids, '%s propery not found in %s property' % (EMAIL_PID, PROPERTY_SHEET)) 64 self.assert_(NOTIFICATION_PID in property_ids, '%s propery not found in %s property' % (NOTIFICATION_PID, PROPERTY_SHEET)) 65 self.assert_(APPROVE_NOTIFICATION_PID in property_ids, '%s propery not found in %s property' % (APPROVE_NOTIFICATION_PID, PROPERTY_SHEET)) 66 self.assert_(PUBLISHED_NOTIFICATION_PID in property_ids, '%s propery not found in %s property' % (PUBLISHED_NOTIFICATION_PID, PROPERTY_SHEET)) 65 67 self.assert_(MODERATION_PID in property_ids, '%s propery not found in %s property' % (MODERATION_PID, PROPERTY_SHEET)) 66 68 self.assert_(ANONYMOUS_COMMENTING_PID in property_ids, '%s propery not found in %s property' % (ANONYMOUS_COMMENTING_PID, PROPERTY_SHEET)) qPloneComments/trunk/utils.py
r207 r208 14 14 15 15 # Send notification e-mail on 16 # Discussion_Reply17 def send_email(reply, context ):16 # Possible values for state: ["approve", "published"] 17 def send_email(reply, context, state="approve"): 18 18 # Check is notification active 19 notify = getProp(context, "Enable_Notification", False) 19 send_result = 0 20 notify = False 21 if state=="approve": 22 notify = getProp(context, "Enable_Approve_Notification", False) 23 elif state=="published": 24 notify = getProp(context, "Enable_Published_Notification", False) 20 25 if not notify: 21 return 26 return send_result 27 22 28 # Get parent object 23 29 parent = reply.inReplyTo() … … 30 36 break 31 37 32 # Get discussion manager's email 33 admin_email = getProp(context, "Email_Discussion_Manager", None) 38 # Get portal admin e-mail 39 portal = getToolByName(context, 'portal_url').getPortalObject() 40 from_address = portal.getProperty('email_from_address') 34 41 35 # Set sending email to creator's or admin's one 36 creator = parent.Creator() 37 if creator: 38 creator = context.portal_membership.getMemberById(creator) 42 # Get email address based on state 43 to_address = None 44 if state=="published": 45 creator = parent.Creator() 46 if creator: 47 mtool = getToolByName(context, 'portal_membership') 48 creator = mtool.getMemberById(creator) 49 to_address = creator.getProperty('email', None) 50 elif state=="approve": 51 to_address = getProp(context, "Email_Discussion_Manager", None) 52 53 # Combine and send email 54 if to_address: 55 if state=="published": 56 template = getattr(context, 'published_comment_template') 57 elif state=="approve": 58 template = getattr(context, 'approve_comment_template') 59 60 organization_name = getProp(context, "Email_Subject_Prefix", "") 61 message = template(obj=parent, mto=to_address, 62 mfrom=from_address, organization_name=organization_name) 39 63 try: 40 email = creator.getProperty('email',None) 64 host = context.MailHost 65 host.send( message ) 66 send_result = 1 41 67 except: 42 email = admin_email 43 if not email: 44 email = admin_email 45 else: 46 email = admin_email 47 # Combine and send email 48 if email: 49 organization_name = getProp(context, "Email_Subject_Prefix", "") 50 subject = "New comment added" 51 bottom_sign = "Support Team." 52 if organization_name: 53 subject = "[%s] %s" % (organization_name, subject) 54 bottom_sign = "%s %s" % (organization_name, bottom_sign) 55 56 body = context.comment_template(obj=parent, 57 mto=email, 58 msubject=subject, 59 mfrom=admin_email, 60 mbsign=bottom_sign) 61 mh = context.MailHost 62 mh.send(body) 68 send_result = 0 69 return send_result 63 70 64 71
