Changeset 149

Show
Ignore:
Timestamp:
01/04/06 13:27:27
Author:
mylan
Message:

- Add "Email subject prefix" field to product's configlet for substitute in notification's subject and bottom sign.
- Add logic for construct subject and bottom sign of notification.
- Rename and reorganize fields of configlet.
- Make appropriate changes to tests.

Files:

Legend:

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

    r148 r149  
    4949        out.write("Adding %s property sheet to portal_properies\n" % PROPERTY_SHEET ) 
    5050    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 
    5557    out.write("Updating properties of %s property sheet\n" % PROPERTY_SHEET ) 
    5658 
  • qPloneComments/trunk/patch.py

    r148 r149  
    4343 
    4444    # Control of performing moderation 
    45     ifModerate = getProp(self, "Turning_on/off_Moderation", marker=False) 
     45    ifModerate = getProp(self, "Enable_Moderation", marker=False) 
    4646    if ifModerate: 
    4747        from zLOG import LOG 
  • qPloneComments/trunk/skins/qplonecomments/comment_template.pt

    r148 r149  
    99 
    1010-- 
    11 Support Team. 
     11<tal:x replace="options/mbsign"/> 
  • qPloneComments/trunk/skins/qplonecomments/ifModerate.py

    r148 r149  
    1010from Products.qPloneComments.utils import getProp 
    1111 
    12 return getProp(context, "Turning_on/off_Moderation", False) 
     12return getProp(context, "Enable_Moderation", False) 
  • qPloneComments/trunk/skins/qplonecomments/isForAnonymous.py

    r148 r149  
    1010from Products.qPloneComments.utils import getProp 
    1111 
    12 return getProp(context, "Turning_on/off_Anonymous_Commenting", False) 
     12return getProp(context, "Enable_Anonymous_Commenting", False) 
  • qPloneComments/trunk/skins/qplonecomments/prefs_qpc_setup.cpy

    r148 r149  
    2828 
    2929        # Switch anonymouse commenting 
    30         if id == 'Turning_on/off_Anonymous_Commenting': 
     30        if id == 'Enable_Anonymous_Commenting': 
    3131            allow = False 
    3232            if id in request_ids: 
  • qPloneComments/trunk/skins/qplonecomments/prefs_qpc_setup_form.cpt

    r148 r149  
    3131 
    3232            <fieldset> 
    33                 <legend i18n:translate="legend_mailhost_details">qPloneComments setup Details</legend> 
     33                <legend i18n:translate="legend_qpc_notification_legend">qPloneComments setup Details</legend> 
    3434 
    3535                <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; 
    8537                                 isEnabledModeration python:props_sheet.getProperty(property_id, False);" 
    8638                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
     
    9951                           for="isEnabledModeration">Enable moderation.</label> 
    10052                     
    101                     <div class="formHelp" i18n:translate="help_enable_moderation"> 
    102                         If checked, moderation for new comments will be activated. 
    103                     </div> 
    10453                </div> 
    10554 
    10655                <div class="field" 
    107                      tal:define="property_id string:Turning_on/off_Anonymous_Commenting; 
     56                     tal:define="property_id string:Enable_Anonymous_Commenting; 
    10857                                 isEnabledAnonymousCommenting python:props_sheet.getProperty(property_id, False);" 
    10958                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
     
    12069 
    12170                    <label i18n:translate="label_anonymous_commenting"  
    122                            for="isEnabledAnonymousCommenting">Enable commenting for anonymous users.</label> 
     71                           for="isEnabledAnonymousCommenting">Enable anonymous comenting.</label> 
    12372                     
    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;" /> 
    126120                    </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                --> 
    128144 
    129145                <div class="formControls"> 
  • qPloneComments/trunk/skins/qplonecomments/validate_setup.vpy

    r148 r149  
    1212 
    1313form = context.REQUEST.form 
    14 email_key = 'Email_of_discussion_manager' 
     14email_key = 'Email_Discussion_Manager' 
    1515 
    1616if email_key in form: 
  • qPloneComments/trunk/tests/testQPloneComments.py

    r148 r149  
    3232#CONFIGLET_NAME = "qPloneComments config" 
    3333 
    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" 
     34EMAIL_PID = "Email_Discussion_Manager" 
     35NOTIFICATION_PID = "Enable_Notification" 
     36MODERATION_PID = "Enable_Moderation" 
     37ANONYMOUS_COMMENTING_PID = "Enable_Anonymous_Commenting" 
    3838 
    3939 
     
    162162            return [r['name'] for r in getPortalReplyPerm(ReplyToItem) if r['selected']=='SELECTED'] 
    163163        # Simulate switching ON Anonymous Commenting 
    164         self.request.form['Turning_on/off_Anonymous_Commenting'] = 'True' 
     164        self.request.form['Enable_Anonymous_Commenting'] = 'True' 
    165165        self.portal.prefs_qpc_setup() 
    166166        actual_reply_permission = getReplyRoles() 
     
    168168                     "'Reply to Item' permission set for %s. 'Anonymous' role NOT added" %  actual_reply_permission) 
    169169        # 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'] 
    172172        self.portal.prefs_qpc_setup() 
    173173        actual_reply_permission = getReplyRoles() 
     
    178178    def testSwitchONModeration(self): 
    179179        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' 
    182182        self.portal.prefs_qpc_setup() 
    183183        # Create talkback for document and Add comment to my_doc 
     
    202202    def testSwitchOFFModeration(self): 
    203203        self.discussion = self.portal.portal_discussion 
    204         self.request.form['Turning_on/off_Anonymous_Commenting'] = 'True' 
     204        self.request.form['Enable_Anonymous_Commenting'] = 'True' 
    205205        self.portal.prefs_qpc_setup() 
    206206        # Create talkback for document and Add comment to my_doc 
     
    223223    def testNotification(self): 
    224224        # 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') 
    226226        # Create talkback for document and Prepare REQUEST 
    227227        self.portal.portal_discussion.getDiscussionFor(self.my_doc) 
     
    231231 
    232232        # 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") 
    234234        self.assertRaises(socket.error, self.my_doc.discussion_reply, 'Reply 1', 'text of reply') 
    235235        # 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") 
    238238        try: 
    239239            self.my_doc.discussion_reply('Reply 1','text of reply') 
  • qPloneComments/trunk/utils.py

    r148 r149  
    2727def send_email(reply, context): 
    2828    # Check is notification active 
    29     notify = getProp(context, "Turning_on/off_notification", False) 
     29    notify = getProp(context, "Enable_Notification", False) 
    3030    if not notify: 
    3131        return 
     
    4141 
    4242    # Get discussion manager's email 
    43     admin_email = getProp(context, "Email_of_discussion_manager", None) 
     43    admin_email = getProp(context, "Email_Discussion_Manager", None) 
    4444 
    4545    # Set sending email to creator's or admin's one 
     
    5757    # Combine and send email 
    5858    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             
    5966        body = context.comment_template(obj=parent, 
    6067                                        mto=email, 
    61                                         msubject="[Cornicen] New comment added", 
    62                                         mfrom=admin_email) 
     68                                        msubject=subject, 
     69                                        mfrom=admin_email, 
     70                                        mbsign=bottom_sign) 
    6371        mh = context.MailHost 
    6472        mh.send(body)