Changeset 242

Show
Ignore:
Timestamp:
02/02/06 07:58:47
Author:
mylan
Message:

Clean code.
Add recent comment moderation configlet and service scripts.

Files:

Legend:

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

    r241 r242  
    4545    # add Property sheet to portal_properies 
    4646    pp = getToolByName(self, 'portal_properties') 
    47     if not PROPERTY_SHEET in 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) 
    5757    # Tern on Anonymous commenting 
    5858    self.manage_permission(ReplyToItem, ['Anonymous','Manager','Member'], 1) 
    5959 
    60     out.write("Updating properties of %s property sheet\n" % PROPERTY_SHEET
     60    out.write("Updating properties of %s property sheet\n" % 'qPloneComments'
    6161 
    6262    # Add Configlet. Delete old version before adding, if exist one. 
     
    6969    # Add DiscussionManager role to Portal 
    7070    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") 
    7576 
    7677    #  Add 'DiscussionManagers' group 
    7778    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") 
    8082 
    8183    out.write('Installation successfully completed.\n') 
     
    8688    if not pp_ps.hasProperty(id): 
    8789        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') ) 
    8991 
    9092 
     
    104106    # Remove Product's property sheet from portal_properties 
    105107    pp = getToolByName(self, 'portal_properties') 
    106     if PROPERTY_SHEET in 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  
    44SKINS_DIR = "skins" 
    55SKIN_NAME = "qplonecomments" 
    6 PROPERTY_SHEET = "qPloneComments" 
    76 
    87CONFIGLET_ID = "prefs_comments_setup_form" 
  • qPloneComments/trunk/patch.py

    r241 r242  
    44from Products.CMFCore.utils import getToolByName 
    55 
    6 #from config import * 
    76from utils import * 
    87 
     
    3433    else: 
    3534        item.manage_addProperty(id='isAnon', value=value, type='boolean') 
     35 
    3636    item.review_state="private" 
    3737 
    38     item.__of__( self ).indexObject() 
    39  
    4038    item.setReplyTo( self._getDiscussable() ) 
    41  
    4239    self._container[ id ] = item 
    4340 
    4441    # Control of performing moderation 
    45     ifModerate = getProp(self, "Enable_Moderation", marker=False) 
     42    ifModerate = getProp(self, "enable_moderation", marker=False) 
    4643    if ifModerate: 
    4744        roles = ['DiscussionManager'] 
    4845        item.manage_permission('Delete objects', roles, acquire=1) 
    49         #item.manage_permission('Review portal content', roles, acquire=0) 
    5046        item.manage_permission('View', roles, acquire=0) 
    5147    else: 
    5248        item.review_state = "published" 
    5349        item._p_changed = 1 
    54          
     50 
     51    item.__of__( self ).indexObject()         
    5552    return id 
    5653 
  • qPloneComments/trunk/skins/qplonecomments/discussion_publish_comment.py

    r241 r242  
    99## 
    1010from Products.CMFPlone import transaction_note 
     11from Products.CMFCore.utils import getToolByName 
    1112from Products.qPloneComments.utils import publishDiscussion, send_email 
    1213 
     
    1617parent = obj.inReplyTo() 
    1718if parent is not None: 
    18     talkback = context.portal_discussion.getDiscussionFor(parent) 
     19    dtool = getToolByName(context, 'portal_discussion') 
     20    talkback = dtool.getDiscussionFor(parent) 
    1921else: 
    2022    talkback = parent = obj.aq_parent 
  • qPloneComments/trunk/skins/qplonecomments/discussion_reply.cpy

    r241 r242  
    77##bind subpath=traverse_subpath 
    88##parameters=subject,body_text,text_format='plain',username=None,password=None 
     9##title=Reply to content 
     10 
    911from Products.PythonScripts.standard import url_quote_plus 
     12from Products.CMFCore.utils import getToolByName 
    1013from Products.qPloneComments.utils import send_email 
    11 from Products.CMFCore.utils import getToolByName 
    12 from Products.qPloneComments.config import PROPERTY_SHEET 
    1314 
     15mtool = getToolByName(context, 'portal_membership') 
     16dtool = getToolByName(context, 'portal_discussion') 
    1417req = context.REQUEST 
    1518pp = 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 
     20isForAnonymous = pp['qPloneComments'].getProperty('enable_anonymous_commenting', None) 
     21ifModerate = pp['qPloneComments'].getProperty('enable_moderation', None); 
    2022 
    2123if username or password: 
     
    5355    comment_creator = comment_creator 
    5456else: 
    55     member = context.portal_membership.getAuthenticatedMember() 
     57    member = mtool.getAuthenticatedMember() 
    5658    # Get Member Full name.If not entered - get user login name 
    5759    comment_creator = member.getProperty('fullname') 
     
    6365reply = tb.getReply(id) 
    6466 
    65 #XXX THIS NEEDS TO GO AWAY! 
     67# TODO THIS NEEDS TO GO AWAY! 
    6668if hasattr(dtool.aq_explicit, 'cookReply'): 
    6769    dtool.cookReply(reply, text_format='plain') 
    6870 
    6971parent = tb.aq_parent 
    70  
    71 from Products.CMFPlone import transaction_note 
    72 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')) 
    7572 
    7673# Send notification e-mail 
     
    7976    send_notification_message += send_email(reply, context, state="published") 
    8077 
     78from Products.CMFPlone import transaction_note 
     79transaction_note('Added comment to %s at %s' % (parent.title_or_id(), reply.absolute_url())) 
     80 
     81portal_status_message='Comment successfully added.' 
     82 
    8183# Inform user about awaiting moderation 
    82 portal_status_message='Comment successfully added.' 
    8384if ifModerate and reply: 
    8485    portal_status_message='Your comment awaits moderartion.' 
    8586 
    86 return state.set(portal_status_message=portal_status_message) 
     87target = '%s/%s?portal_status_message=%s' % (parent.absolute_url(), parent.getTypeInfo().getActionById('view'), portal_status_message) 
     88 
     89return req.RESPONSE.redirect(target) 
  • qPloneComments/trunk/skins/qplonecomments/discussion_reply_form.cpt

    r241 r242  
    2121          action="talkback" 
    2222          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)"> 
    2424        <fieldset> 
    2525            <legend i18n:translate="legend_comment_details">Comment Details</legend> 
    2626 
    2727            <input type="hidden" name="Creator" value="" 
    28                    tal:attributes="value member/getUserName" 
     28                   tal:attributes="value member/getUserName"  
    2929                   tal:condition="not:isForAnonymous" /> 
    3030 
     
    4545                    <div class="formHelp" i18n:translate="help_name" 
    4646                         tal:condition="isAnon"> 
    47                     Enter your name for sign comment
     47                    Please tell us your name
    4848                    </div> 
    4949 
  • qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup.cpy

    r241 r242  
    88##title= 
    99## 
    10 from Products.qPloneComments.config import PROPERTY_SHEET 
     10from Products.CMFCore.utils import getToolByName 
    1111from Products.qPloneComments.utils import setAnonymCommenting 
    12 from Products.CMFCore.utils import getToolByName 
    1312 
    1413form = context.REQUEST.form 
    1514pp = getToolByName(context, 'portal_properties') 
    16 props_sheet = getattr(pp, PROPERTY_SHEET
     15props_sheet = getattr(pp, 'qPloneComments'
    1716property_maps=[(m['id'], m['type']) for m in props_sheet.propertyMap() if not m['id']=='title'] 
    1817request_ids = form.keys() 
     
    2524        else: 
    2625            kw[id] = False 
    27         if id == 'Enable_Anonymous_Commenting': 
     26 
     27        # Switch anonymouse commenting 
     28        if id == 'enable_anonymous_commenting': 
    2829            allow = False 
    2930            if id in request_ids: 
  • qPloneComments/trunk/skins/qplonecomments/prefs_comments_setup_form.cpt

    r241 r242  
    1111 
    1212    <div metal:define-macro="main" i18n:domain="plone"> 
     13    <div class="configlet"> 
     14    <div class="documentEditable"> 
    1315 
     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    &nbsp; 
     32    </div>         
     33    <!-- End of tabs --> 
     34    <div class="documentContent" metal:define-slot="prefs_content"> 
    1435        <h1 i18n:translate="qpc_setup">qPloneComments Setup</h1> 
    1536 
     
    2647              enctype="multipart/form-data" 
    2748              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');" 
    3050              tal:attributes="action string:${here/getId}/${template/getId}"> 
    3151 
     
    3454 
    3555                <div class="field" 
    36                      tal:define="property_id string:Enable_Moderation; 
     56                     tal:define="property_id string:enable_moderation; 
    3757                                 isEnabledModeration python:props_sheet.getProperty(property_id, False);" 
    3858                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
     
    5474 
    5575                <div class="field" 
    56                      tal:define="property_id string:Enable_Anonymous_Commenting; 
     76                     tal:define="property_id string:enable_anonymous_commenting; 
    5777                                 isEnabledAnonymousCommenting python:props_sheet.getProperty(property_id, False);" 
    5878                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
     
    7494 
    7595                <div class="field" 
    76                      tal:define="property_id string:Enable_Published_Notification; 
     96                     tal:define="property_id string:enable_published_notification; 
    7797                                 isEnabledPublishedNotification python:props_sheet.getProperty(property_id, False);" 
    7898                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
     
    93113 
    94114                <div class="field" 
    95                      tal:define="property_id string:Enable_Approve_Notification; 
     115                     tal:define="property_id string:enable_approve_notification; 
    96116                                 isEnableApproveNotification python:props_sheet.getProperty(property_id, False);" 
    97117                     tal:condition="python:props_sheet.hasProperty(property_id)"> 
     
    111131                </div> 
    112132 
    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> 
    131148 
    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. 
    139168                    </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> 
    164178 
    165179                <div class="formControls"> 
     
    178192        </form> 
    179193    </div> 
    180  
     194    </div> 
     195    </div> 
     196    </div> 
    181197</div> 
    182  
    183198</body> 
    184  
    185199</html> 
  • qPloneComments/trunk/skins/qplonecomments/validate_setup.vpy

    r241 r242  
    88##parameters= 
    99##title=validates qpc setup 
    10  
     10## 
    1111from Products.CMFCore.utils import getToolByName 
    1212 
    1313form = context.REQUEST.form 
    14 email_key = 'Email_Discussion_Manager' 
     14email_key = 'email_discussion_manager' 
    1515 
    1616if email_key in form: 
  • qPloneComments/trunk/skins/qplonecomments/validate_talkback.vpy

    r241 r242  
    88##parameters=subject='',body_text='' 
    99##title=validates a discussion entry 
    10  
     10## 
    1111from Products.CMFCore.utils import getToolByName 
    12 from Products.qPloneComments.config import PROPERTY_SHEET 
    1312 
    1413if not subject: 
     
    1918 
    2019pp = getToolByName(context, 'portal_properties') 
    21 isForAnonymous = pp[PROPERTY_SHEET].getProperty('Enable_Anonymous_Commenting', None) 
     20isForAnonymous = pp['qPloneComments'].getProperty('enable_anonymous_commenting', None) 
    2221if isForAnonymous: 
    2322    pm = getToolByName(context, 'portal_membership') 
  • qPloneComments/trunk/skins/qplonecomments/viewThreadsAtBottom.pt

    r241 r242  
    99                 portal_discussion portal/portal_discussion; 
    1010                 isDiscussionAllowed python:portal_discussion.isDiscussionAllowedFor(here); 
    11                  userIsAnonymous isAnon; 
    1211                 hereTypeInfo python:request.get('this_typeinfo', here.getTypeInfo()); 
    1312                 view_action python:hereTypeInfo.getActionById('view'); 
     
    3029        </form> 
    3130 
    32         <form tal:condition="python:userIsAnonymous and not userHasReplyPermission" 
     31        <form tal:condition="python:isAnon and not userHasReplyPermission" 
    3332              tal:define="pss modules/Products/PythonScripts/standard" 
    3433              tal:attributes="action python:'%s/login_form?came_from=%s' % 
     
    5049                <div class="comment" 
    5150                     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);"> 
    5352                    <h3> 
    5453                        <tal:block replace="structure portal/discussionitem_icon.gif"/> 
  • qPloneComments/trunk/tests/testQPloneCommentsCommenting.py

    r241 r242  
    166166        pp = getToolByName(self.portal, 'portal_properties') 
    167167        config_ps = getattr(pp, 'qPloneComments', None) 
    168         EnableAnonymComm = getattr(config_ps, "Enable_Anonymous_Commenting") 
     168        EnableAnonymComm = getattr(config_ps, "enable_anonymous_commenting") 
    169169        # Group users depending on Anonymous commenting enabling/disabling 
    170170        if EnableAnonymComm: 
     
    277277        pp = getToolByName(self.portal, 'portal_properties') 
    278278        config_ps = getattr(pp, 'qPloneComments', None) 
    279         EnableAnonymComm = getattr(config_ps, "Enable_Anonymous_Commenting") 
     279        EnableAnonymComm = getattr(config_ps, "enable_anonymous_commenting") 
    280280        # Group users depending on Anonymous commenting enabling/disabling 
    281281        if EnableAnonymComm: 
     
    344344        # Preparation for functional testing 
    345345        # 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' 
    348348        self.portal.prefs_comments_setup() 
    349349        # Initialize base classes 
     
    358358        # Preparation for functional testing 
    359359        # Tern On Moderation and tern off Anonymous commenting  
    360         self.request.form['Enable_Moderation'] = 'True' 
     360        self.request.form['enable_moderation'] = 'True' 
    361361        self.portal.prefs_comments_setup() 
    362362        # Initialize base classes 
     
    372372        # Preparation for functional testing 
    373373        # Tern On Anonymous commenting and tern off  Moderation 
    374         self.request.form['Enable_Anonymous_Commenting'] = 'True' 
     374        self.request.form['enable_anonymous_commenting'] = 'True' 
    375375        self.portal.prefs_comments_setup() 
    376376        # Initialize base classes 
  • qPloneComments/trunk/tests/testQPloneCommentsConfiglet.py

    r241 r242  
    7575        self.login('dm') 
    7676        # 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') 
    7878        member = self.portal.portal_membership.getAuthenticatedMember() 
    7979        member.setMemberProperties({'email':'creator@test.com'}) 
     
    9191            return [r['name'] for r in getPortalReplyPerm(ReplyToItem) if r['selected']=='SELECTED'] 
    9292        # Simulate switching ON Anonymous Commenting 
    93         self.request.form['Enable_Anonymous_Commenting'] = 'True' 
     93        self.request.form['enable_anonymous_commenting'] = 'True' 
    9494        self.portal.prefs_comments_setup() 
    9595        actual_reply_permission = getReplyRoles() 
     
    9797                     "'Reply to Item' permission set for %s. 'Anonymous' role NOT added" %  actual_reply_permission) 
    9898        # 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'] 
    101101        self.portal.prefs_comments_setup() 
    102102        actual_reply_permission = getReplyRoles() 
     
    108108        addUsers(self) 
    109109        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' 
    112112        self.portal.prefs_comments_setup() 
    113113        # Create talkback for document and Add comment to my_doc 
     
    132132        addUsers(self) 
    133133        self.discussion = self.portal.portal_discussion 
    134         self.request.form['Enable_Anonymous_Commenting'] = 'True' 
     134        self.request.form['enable_anonymous_commenting'] = 'True' 
    135135        self.portal.prefs_comments_setup() 
    136136        # Create talkback for document and Add comment to my_doc 
     
    153153    def testApproveNotification(self): 
    154154        # Check ON Notification Anonymous Commenting 
    155         self.request.form['Enable_Approve_Notification'] = 'True' 
     155        self.request.form['enable_approve_notification'] = 'True' 
    156156        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") 
    158158 
    159159        # 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'] 
    162162        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") 
    164164 
    165165 
    166166    def testPublishedNotification(self): 
    167167        # Check ON Notification Anonymous Commenting 
    168         self.request.form['Enable_Published_Notification'] = 'True' 
     168        self.request.form['enable_published_notification'] = 'True' 
    169169        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") 
    171171 
    172172        # 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'] 
    175175        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") 
    177177 
    178178 
  • qPloneComments/trunk/tests/testQPloneCommentsInstall.py

    r241 r242  
    1616CONFIGLET_ID = "prefs_comments_setup_form" 
    1717 
    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" 
     18EMAIL_PID = "email_discussion_manager" 
     19APPROVE_NOTIFICATION_PID = "enable_approve_notification" 
     20PUBLISHED_NOTIFICATION_PID = "enable_published_notification" 
     21MODERATION_PID = "enable_moderation" 
     22ANONYMOUS_COMMENTING_PID = "enable_anonymous_commenting" 
    2323 
    2424PloneTestCase.installProduct(PRODUCT) 
  • qPloneComments/trunk/tests/testQPloneCommentsNotification.py

    r241 r242  
    2424 
    2525    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) 
    2828 
    2929 
     
    5454        self.login('dm') 
    5555        # 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') 
    5757        member = self.portal.portal_membership.getAuthenticatedMember() 
    5858        member.setMemberProperties({'email':'creator@test.com'}) 
     
    108108 
    109109    def testOFFModerationApprovePublished(self): 
    110         self.prefs._updateProperty('Enable_Moderation', 0) 
     110        self.prefs._updateProperty('enable_moderation', 0) 
    111111 
    112112        # Test Enable Approve Notification & Enable Published Notification 
     
    118118     
    119119    def testOFFModerationApprove(self): 
    120         self.prefs._updateProperty('Enable_Moderation', 0) 
     120        self.prefs._updateProperty('enable_moderation', 0) 
    121121         
    122122        # Test Enable Approve Notification & Disable Published Notification 
     
    128128 
    129129    def testOFFModerationPublished(self):  
    130         self.prefs._updateProperty('Enable_Moderation', 0) 
     130        self.prefs._updateProperty('enable_moderation', 0) 
    131131         
    132132        # Test Enable Published Notification  & Disable Approve Notification 
     
    138138 
    139139    def testOFFModeration(self):  
    140         self.prefs._updateProperty('Enable_Moderation', 0) 
     140        self.prefs._updateProperty('enable_moderation', 0) 
    141141         
    142142        # Test Disable Published Notification & Disable Approve Notification 
  • qPloneComments/trunk/utils.py

    r241 r242  
    11from Products.CMFCore.utils import getToolByName 
    2 from config import * 
    32 
    43# Get apropriate property from (propery_sheeet) configlet 
     
    65    result = marker 
    76    pp = getToolByName(self, 'portal_properties') 
    8     config_ps = getattr(pp, PROPERTY_SHEET, None) 
     7    config_ps = getattr(pp, 'qPloneComments', None) 
    98    if config_ps: 
    109        result =  getattr(config_ps, prop_name, marker) 
     
    1211 
    1312 
    14 # Send notification e-mail on  
     13# Send notification e-mail on Discussion_Reply  
    1514# Possible values for state: ["approve", "published"] 
    1615def send_email(reply, context, state="approve"): 
     
    1817    notify = False 
    1918    if state=="approve": 
    20         notify = getProp(context, "Enable_Approve_Notification", False) 
     19        notify = getProp(context, "enable_approve_notification", False) 
    2120    elif state=="published": 
    22         notify = getProp(context, "Enable_Published_Notification", False) 
     21        notify = getProp(context, "enable_published_notification", False) 
    2322    if not notify: 
    2423        return 0 
     
    3736    portal = getToolByName(context, 'portal_url').getPortalObject() 
    3837    from_address = portal.getProperty('email_from_address') 
    39  
     38     
    4039    # Get email address based on state 
    4140    to_address = None 
     
    4847                to_address = creator.getProperty('email', None) 
    4948    elif state=="approve": 
    50         to_address = getProp(context, "Email_Discussion_Manager", None) 
     49        to_address = getProp(context, "email_discussion_manager", None) 
    5150 
    5251    # Combine and send email 
     
    5756            template = getattr(context, 'approve_comment_template') 
    5857 
    59         organization_name = getProp(context, "Email_Subject_Prefix", "") 
     58        organization_name = getProp(context, "email_subject_prefix", "") 
    6059        message = template(obj=parent, mto=to_address, 
    6160                           mfrom=from_address, organization_name=organization_name) 
     
    7372    self.manage_permission('View', roles, acquire=1) 
    7473    self._p_changed = 1 
     74    self.reindexObject() 
    7575 
    7676 
     
    8282        portal.manage_permission('Reply to item', ['Manager','Member'], 1) 
    8383 
    84          
     84