Changeset 208

Show
Ignore:
Timestamp:
01/25/06 11:29:26
Author:
mylan
Message:

- Separate templates for *discussion manager* (for approve comment) and for *creator* (that comment added and published)
- Add "Enable Document Owner notification on new comments."

and replaced old "Enable e-mail notification on new coments." with "Enable Discussion Manager notification on new comments."
for 2.0.5 Plone release

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/trunk/Extensions/Install.py

    r207 r208  
    5151    updateProperty(props_sheet, id="Enable_Moderation", value="True", property_type='boolean', out=out) 
    5252    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) 
    5455    updateProperty(props_sheet, id="Email_Discussion_Manager", value="", property_type='string', out=out) 
    5556    updateProperty(props_sheet, id="Email_Subject_Prefix", value="", property_type='string', out=out) 
  • qPloneComments/trunk/skins/qplonecomments/discussion_reply.cpy

    r207 r208  
    1414req = context.REQUEST 
    1515pp = getToolByName(context,'portal_properties') 
     16mtool = getToolByName(context, 'portal_membership') 
     17dtool = getToolByName(context, 'portal_discussion') 
     18isForAnonymous = pp[PROPERTY_SHEET].getProperty('Enable_Anonymous_Commenting', None) 
     19ifModerate = pp[PROPERTY_SHEET].getProperty('Enable_Moderation', None); 
    1620 
    1721if username or password: 
     
    4448######################################################### 
    4549# Get discussion item (reply) author and creating reply # 
    46 isForAnonymous = pp[PROPERTY_SHEET].getProperty('Enable_Anonymous_Commenting', None) 
    4750comment_creator = req.get('Creator', None) 
    4851if isForAnonymous and comment_creator: 
     
    6164 
    6265#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') 
     66if hasattr(dtool.aq_explicit, 'cookReply'): 
     67    dtool.cookReply(reply, text_format='plain') 
    6668 
    6769parent = tb.aq_parent 
     
    7375 
    7476# Send notification e-mail 
    75 send_email(reply, context) 
     77send_notification_message = send_email(reply, context, state="approve") 
     78if not ifModerate: 
     79    send_notification_message += send_email(reply, context, state="published") 
    7680 
    7781# Inform user about awaiting moderation 
    7882portal_status_message='Comment successfully added.' 
    79 ifModerate = pp[PROPERTY_SHEET].getProperty('Enable_Moderation', None); 
    8083if ifModerate and reply: 
    8184    portal_status_message='Your comment awaits moderartion.' 
  • qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy

    r207 r208  
    4040props_sheet.manage_changeProperties(kw) 
    4141 
    42 return state.set(portal_status_message='Document changes saved.') 
     42return state.set(portal_status_message='qPloneComments configuration changes saved.') 
  • qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup_form.cpt

    r207 r208  
    7474 
    7575                <div class="field" 
    76                      tal:define="property_id string:Enable_Notification; 
    77                                  isEnabledNotification 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);" 
    7878                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
    7979 
    8080                    <input type="checkbox"  
    8181                           class="noborder" 
    82                            name="isEnabledNotification" 
    83                            id="isEnabledNotification" 
     82                           name="isEnabledPublishedNotification" 
     83                           id="isEnabledPublishedNotification" 
    8484                           tabindex ="" 
    8585                           tal:attributes="name property_id; 
    86                                            value isEnabledNotification; 
    87                                            checked python:test(isEnabledNotification, 'True', ''); 
     86                                           value isEnabledPublishedNotification; 
     87                                           checked python:test(isEnabledPublishedNotification, 'True', ''); 
    8888                                           tabindex tabindex/next;"/> 
    8989 
    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> 
    92111                </div> 
    93112 
     
    129148                        <div class="formHelp" id="organization_name_help" 
    130149                             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. 
    132152                        </div> 
    133153                         
  • qPloneComments/trunk/tests/testQPloneCommentsInstall.py

    r207 r208  
    1717 
    1818EMAIL_PID = "Email_Discussion_Manager" 
    19 NOTIFICATION_PID = "Enable_Notification" 
     19APPROVE_NOTIFICATION_PID = "Enable_Approve_Notification" 
     20PUBLISHED_NOTIFICATION_PID = "Enable_Published_Notification" 
    2021MODERATION_PID = "Enable_Moderation" 
    2122ANONYMOUS_COMMENTING_PID = "Enable_Anonymous_Commenting" 
     
    6263        property_ids = portal_properties[PROPERTY_SHEET].propertyIds() 
    6364        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)) 
    6567        self.assert_(MODERATION_PID in property_ids, '%s propery not found in %s property' % (MODERATION_PID, PROPERTY_SHEET)) 
    6668        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  
    1414 
    1515# Send notification e-mail on  
    16 # Discussion_Reply  
    17 def send_email(reply, context): 
     16# Possible values for state: ["approve", "published"] 
     17def send_email(reply, context, state="approve"): 
    1818    # 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) 
    2025    if not notify: 
    21         return 
     26        return send_result 
     27 
    2228    # Get parent object 
    2329    parent = reply.inReplyTo() 
     
    3036           break 
    3137 
    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') 
    3441 
    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) 
    3963        try: 
    40             email = creator.getProperty('email',None) 
     64            host = context.MailHost  
     65            host.send( message ) 
     66            send_result = 1 
    4167        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 
    6370 
    6471