Changeset 561

Show
Ignore:
Timestamp:
10/05/06 11:00:07
Author:
crchemist
Message:

Clean up code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/branches/plone-2.5/skins/qplonecomments/prefs_recent_comments_delete.cpy

    r560 r561  
    1 <<<<<<< .working 
    21## Script (Python) "prefs_recent_comments_delete" 
    32##bind container=container 
     
    98##title= 
    109## 
    11  
    1210from Products.CMFCore.utils import getToolByName 
    1311from Products.qPloneComments.utils import manage_mails 
     
    3129    manage_mails(comment, context, 'deleting') 
    3230 
    33 psm = comment_ids and 'Comments was successfully deleted.' or 'Please select items to be processed.' 
     31psm = comment_ids and 'Comment(s) deleted.' or 'Please select items to be processed.' 
    3432return state.set(portal_status_message=psm) 
    35 ======= 
    36 ## Script (Python) "prefs_recent_comments_delete" 
    37 ##bind container=container 
    38 ##bind context=context 
    39 ##bind namespace= 
    40 ##bind script=script 
    41 ##bind subpath=traverse_subpath 
    42 ##parameters= 
    43 ##title= 
    44 ## 
    45  
    46 from Products.CMFCore.utils import getToolByName 
    47 portal_discussion = getToolByName(context, "portal_discussion") 
    48 portal_catalog = getToolByName(context, "portal_catalog") 
    49  
    50 request = context.REQUEST 
    51 comment_ids = request.get('ids') 
    52  
    53 for comment_id in comment_ids: 
    54     comment = portal_catalog(id=comment_id,portal_type='Discussion Item')[0].getObject() 
    55  
    56     parent = comment.inReplyTo() 
    57     if parent is not None: 
    58         talkback = portal_discussion.getDiscussionFor(parent) 
    59     else: 
    60         talkback = parent = comment.aq_parent 
    61  
    62     talkback.deleteReply( comment_id ) 
    63  
    64 return state.set(portal_status_message='Comment(s) deleted.') 
    65  
    66 >>>>>>> .merge-right.r488 
  • qPloneComments/branches/plone-2.5/utils.py

    r560 r561  
    112112        di_parrent = getDIParent(reply) 
    113113        if di_parrent: 
    114             args={'mto': getEmail(di_parrent, context), 
    115                   'mfrom': admin_email, 
    116                   'obj': reply_parent, 
    117                   'organization_name': organization_name, 
    118                   'name': creator_name} 
     114            user_email = getEmail(di_parrent, context) 
     115            if user_email: 
     116                args={'mto': user_email, 
     117                      'mfrom': admin_email, 
     118                      'obj': reply_parent, 
     119                      'organization_name': organization_name, 
     120                      'name': creator_name} 
     121            else: 
     122                args = {} 
    119123        else: 
    120124            args = {} 
     
    122126    elif state == 'enable_published_notification': 
    123127        template = 'published_comment_template' 
    124         args={'mto':getParentOwnerEmail(reply, context), 
    125               'mfrom':admin_email, 
    126               'obj':reply_parent, 
    127               'organization_name':organization_name} 
     128        user_email = getParentOwnerEmail(reply, context) 
     129        if user_email: 
     130            args={'mto':user_email, 
     131                  'mfrom':admin_email, 
     132                  'obj':reply_parent, 
     133                  'organization_name':organization_name} 
     134        else: 
     135            args = {} 
    128136 
    129137    elif state == 'enable_approve_notification': 
    130138        template = 'approve_comment_template' 
    131         args={'mto':getProp(context, "email_discussion_manager", None), 
    132               'mfrom':admin_email, 
    133               'obj':reply_parent, 
    134               'organization_name':organization_name} 
     139        user_email = getProp(context, "email_discussion_manager", None) 
     140        if user_email: 
     141            args={'mto':user_email, 
     142                  'mfrom':admin_email, 
     143                  'obj':reply_parent, 
     144                  'organization_name':organization_name} 
     145        else: 
     146            args = {} 
     147 
    135148    if args: 
    136149        return send(context, template, args)