Changeset 1717 in products for quintagroup.plonecomments/trunk/quintagroup/plonecomments/utils.py
- Timestamp:
- Feb 11, 2010 4:39:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.plonecomments/trunk/quintagroup/plonecomments/utils.py
r1640 r1717 1 1 import smtplib 2 from Products.CMFPlone import MessageFactory 2 from zope.i18n import translate 3 from zope.i18nmessageid import MessageFactory 4 _ = MessageFactory("quintagroup.plonecomments") 3 5 from Products.CMFCore.utils import getToolByName 4 from Products.CMFPlone import PloneMessageFactory as _5 6 from config import warning 6 7 … … 108 109 creator_name = reply.getOwnerTuple()[1] 109 110 admin_email = context.portal_url.getPortalObject().getProperty('email_from_address') 110 111 translate = getToolByName(context, 'translation_service').translate 111 112 subject = '' 112 113 if state == 'enable_approve_user_notification': 113 subject = 'Your comment on %s is now published' % getParent(context).Title() 114 subject = translate(_(u"approve_user_notification_subject", 115 default=u"Your comment on ${title} is now published", 116 mapping={u"title" : getParent(context).Title()}), 117 context=context.REQUEST) 114 118 if user_email: 115 119 template = 'notify_comment_template' … … 123 127 124 128 elif state == 'enable_rejected_user_notification': 125 subject = 'Your comment on %s was not approved' % getParent(context).Title() 129 subject = translate(_(u"rejected_user_notification_subject", 130 default=u"Your comment on ${title} was not approved", 131 mapping={u"title" : getParent(context).Title()}), 132 context=context.REQUEST) 126 133 if user_email: 127 134 template = 'rejected_comment_template' … … 136 143 elif state == 'enable_reply_user_notification': 137 144 template = 'reply_notify_template' 138 subject = 'Someone replied to your comment on %s' % getParent(context).Title() 145 subject = translate(_(u"reply_user_notification_subject", 146 default=u"Someone replied to your comment on ${title}", 147 mapping={u"title" : getParent(context).Title()}), 148 context=context.REQUEST) 139 149 di_parrent = getDIParent(reply) 140 150 if di_parrent: … … 159 169 'obj':reply_parent, 160 170 'organization_name':organization_name} 161 subject = '[%s] New comment added' % organization_name 171 subject = translate(_(u"published_notification_subject", 172 default=u"[${organization_name}] New comment added", 173 mapping={u"organization_name" : organization_name}), 174 context=context.REQUEST) 162 175 else: 163 176 args = {} … … 171 184 'obj':reply_parent, 172 185 'organization_name':organization_name} 173 subject = '[%s] New comment awaits moderation' % organization_name 186 subject = translate(_(u"approve_notification_subject", 187 default=u"[${organization_name}] New comment awaits moderation", 188 mapping={u"organization_name" : organization_name}), 189 context=context.REQUEST) 174 190 else: 175 191 args = {} … … 192 208 'comment_id':comment_id, 193 209 'comment_desc':comment.description, 194 'comment_text':comment.text 195 } 196 subject = '[%s] A comment on "%s" has been reported for abuse.' \ 197 % (organization_name, getParent(context).Title()) 210 'comment_text':comment.text} 211 subject = translate(_(u"report_abuse_subject", 212 default=u"[${organization_name}] A comment on ${title} has been reported for abuse.", 213 mapping={u"organization_name" : organization_name, u"title" : getParent(context).Title()}), 214 context=context.REQUEST) 198 215 else: 199 216 args = {} … … 205 222 host = context.plone_utils.getMailHost() 206 223 try: 207 host.secureSend(msg, user_email, admin_email, 208 subject = subject, 209 subtype = 'plain', 210 debug = False, 211 charset = charset) 212 except smtplib.SMTPRecipientsRefused: 213 log.error(_('SMTPRecipientsRefused: Could not send the email ' 214 'notification. Have you configured an email server for Plone?')) 224 host.secureSend(msg, user_email, admin_email, subject = subject, 225 subtype = 'plain', debug = False, charset = charset) 226 except (smtplib.SMTPRecipientsRefused,smtplib.SMTPServerDisconnected): 227 setStatusMsg(None, context, 228 _('Could not send the email notification. Have you configured an email server for Plone?')) 215 229 216 230 def setStatusMsg(state, context, msg):
Note: See TracChangeset
for help on using the changeset viewer.