Exemplo n.º 1
0
def sendNotification(self, obj):
    sm = ISubscriptionManager(obj)

    portal_url = getToolByName(obj, 'portal_url')
    project = obj.getProject()
    company = project.getCompany()

    subject = '[%s] %s' % (project.Title(), obj.Title())

    mtool = getToolByName(obj, 'portal_membership')
    member = mtool.getAuthenticatedMember()
    fullname = member.getProperty('fullname')
    email = member.getProperty('email')
    body = translate(_(
        u'body_email',
        default=
        '${user_name} <${user_email}> invitation you view ${obj_title}. \n\nVisit URL:  ${obj_url} \n \n--\nDO NOT REPLY TO THIS EMAIL.\nTo comment on this content, visit: \n${obj_url}',
        mapping={
            u'obj_url': obj.absolute_url(),
            u'user_name': fullname or member.getId(),
            u'user_email': email,
            u'obj_title': obj.Title()
        }),
                     context=self.request)

    sm.sendMail(subject=subject, body=body, includeme=True)
Exemplo n.º 2
0
def sendNotification(self, msg):
        sm = ISubscriptionManager(msg)

        portal_url = getToolByName(msg, 'portal_url')
        project = msg.getProject()
        company =project.getCompany()

        # attachments in msg
        attachments_msg = ''
        attachments = msg.getAttachedImagesAndFiles()
        image_urls = [img.absolute_url() for img in attachments[0]]
        file_urls = [file.absolute_url() for file in attachments[1]]
        len_attachments = len(image_urls + file_urls)

        if image_urls or file_urls:
            attachments_msg = translate(_(u'attachment_msg_msg', default='This message contains ${len_attachments} attachment(s):\n ', mapping={u'len_attachments':len_attachments}), context=self.request)
            for url in (image_urls + file_urls):
                url = url + '\n'
                attachments_msg+=url

        subject = '[%s] %s' % (project.Title(), msg.Title())

        mtool = getToolByName(msg, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        fullname = member.getProperty('fullname')
        email = member.getProperty('email')
        body = translate(_(u'body_email',
                           default='A new message has been posted. DO NOT REPLY TO THIS EMAIL. To comment on this message, visit: \n ${msg_url} \n \n${user_name} <${user_email}> said:\n--------------------------------------------------------------- \n${msg_body} \n${attachments} \n \n--\nDO NOT REPLY TO THIS EMAIL.\nTo comment on this message, visit: \n${msg_url}',
            mapping={u'msg_url':msg.absolute_url(),
                     u'user_name':fullname or member.getId(),
                     u'user_email':email,
                     u'msg_body':msg.getRawText(),
                     u'attachments':attachments_msg}),context=self.request)

        sm.sendMail(subject=subject, body=body, includeme=True)
Exemplo n.º 3
0
def sendNotification(self, msg):
    sm = ISubscriptionManager(msg)

    portal_url = getToolByName(msg, 'portal_url')
    portal = portal_url.getPortalObject()
    subject = '[%s] %s' % (portal.Title(), msg.Title())

    mtool = getToolByName(msg, 'portal_membership')
    member = mtool.getAuthenticatedMember()
    fullname = member.getProperty('fullname')
    email = member.getProperty('email')

    body = translate(_(
        u'mail_body',
        default=
        'A file submitted. DO NOT REPLY TO THIS EMAIL.\n\nSubmitted by ${user_name} <${user_email}>: \n\nFile: ${filename}\nDownload: ${file_url}\n\n${description}',
        mapping={
            u'file_url': msg.absolute_url() + '/@@file_view',
            u'user_name': fullname or member.getId(),
            u'user_email': email,
            u'filename': msg.Title(),
            u'description': msg.Description()
        }),
                     context=self.request)
    sm.sendMail(subject=subject, body=body, includeme=True)
Exemplo n.º 4
0
def sendNotification(self, msg):
    sm = ISubscriptionManager(msg)

    portal_url = getToolByName(msg, "portal_url")
    portal = portal_url.getPortalObject()
    subject = "[%s] %s" % (portal.Title(), msg.Title())

    mtool = getToolByName(msg, "portal_membership")
    member = mtool.getAuthenticatedMember()
    fullname = member.getProperty("fullname")
    email = member.getProperty("email")

    body = translate(
        _(
            u"mail_body",
            default="A file submitted. DO NOT REPLY TO THIS EMAIL.\n\nSubmitted by ${user_name} <${user_email}>: \n\nFile: ${filename}\nDownload: ${file_url}\n\n${description}",
            mapping={
                u"file_url": msg.absolute_url() + "/@@file_view",
                u"user_name": fullname or member.getId(),
                u"user_email": email,
                u"filename": msg.Title(),
                u"description": msg.Description(),
            },
        ),
        context=self.request,
    )
    sm.sendMail(subject=subject, body=body, includeme=True)
Exemplo n.º 5
0
    def _addComment(self, text, attaches=[]):
        cm = ICommentsManager(self.context)
        comment = cm.addComment(text, attaches)

        # send notifications
        msg = self.context.aq_inner
        type_name = msg.portal_type
        sm = ISubscriptionManager(msg)

        portal_url = getToolByName(msg, 'portal_url')

        project = msg.getProject()
        company = project.getCompany()

        # attachments in msg
        attachments_msg = ''
        attachments = self.attachable() and comment.getCommentAttaches() or [(), ()]
        image_urls = [img.absolute_url() for img in attachments[0]]
        file_urls = [file.absolute_url() for file in attachments[1]]
        len_attachments = len(image_urls + file_urls)

        if image_urls or file_urls:
            attachments_msg = translate(_(u'attachments_msg',
                                        default='This comment contains ${len_attachments} attachment(s): \n ',
                                        mapping={u'len_attachments':len_attachments}),
                                        context=self.request) 
            for url in (image_urls + file_urls):
                url = url + '/@@file_view' + '\n'
                attachments_msg+=url

        subject = '[%s] %s' % (project.Title(), comment.Title())

        mtool = getToolByName(msg, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        fullname = member.getProperty('fullname')
        email = member.getProperty('email')

        if type_name in ['Image', 'File']:
            bc_url = '%s/@@file_view' % msg.absolute_url()
        else:
            bc_url = msg.absolute_url()


        body = translate(_(u'mail_body',
                        default='${project_name} of the ${company_name} have a new comment posted. DO NOT REPLY TO THIS EMAIL. To comment on this message, visit:\n${msg_url}\n\n${user_name} <${user_email}> said:\n--------------------------------------------------------------------------\n${msg_body}\n\n${attachments}\n\n--\nDO NOT REPLY TO THIS EMAIL.\nTo comment on this message, visit:\n${msg_url}', 
                        mapping={u'company_name':company.Title(),
                               u'project_name':project.Title(),
                               u'msg_url':bc_url,
                               u'user_name':fullname or member.getId(),
                               u'user_email':email,
                               u'msg_body':text,
                               u'attachments':attachments_msg}),
                        context=self.request)
        sm.sendMail(subject=subject, body=body)
        sm.subscribeAuthenticatedMember()
        return comment
Exemplo n.º 6
0
def sendNotification(self, obj):
        sm = ISubscriptionManager(obj)

        portal_url = getToolByName(obj, 'portal_url')
        project = obj.getProject()
        company =project.getCompany()

        subject = '[%s] %s' % (project.Title(), obj.Title())

        mtool = getToolByName(obj, 'portal_membership')
        member = mtool.getAuthenticatedMember()
        fullname = member.getProperty('fullname')
        email = member.getProperty('email')
        body = translate(_(u'body_email', default='${user_name} <${user_email}> invitation you view ${obj_title}. \n\nVisit URL:  ${obj_url} \n \n--\nDO NOT REPLY TO THIS EMAIL.\nTo comment on this content, visit: \n${obj_url}',
            mapping={u'obj_url':obj.absolute_url(),
                     u'user_name':fullname or member.getId(),
                     u'user_email':email,
                     u'obj_title':obj.Title()}),context=self.request)

        sm.sendMail(subject=subject, body=body, includeme=True)
Exemplo n.º 7
0
    def _addComment(self, text, attaches=[]):
        cm = ICommentsManager(self.context)
        comment = cm.addComment(text, attaches)

        # send notifications
        msg = self.context.aq_inner
        type_name = msg.portal_type
        sm = ISubscriptionManager(msg)

        portal_url = getToolByName(msg, "portal_url")

        project = msg.getProject()
        company = project.getCompany()

        # attachments in msg
        attachments_msg = ""
        attachments = self.attachable() and comment.getCommentAttaches() or [(), ()]
        image_urls = [img.absolute_url() for img in attachments[0]]
        file_urls = [file.absolute_url() for file in attachments[1]]
        len_attachments = len(image_urls + file_urls)

        if image_urls or file_urls:
            attachments_msg = translate(
                _(
                    u"attachments_msg",
                    default="This comment contains ${len_attachments} attachment(s): \n ",
                    mapping={u"len_attachments": len_attachments},
                ),
                context=self.request,
            )
            for url in image_urls + file_urls:
                url = url + "/@@file_view" + "\n"
                attachments_msg += url

        subject = "[%s] %s" % (project.Title(), comment.Title())

        mtool = getToolByName(msg, "portal_membership")
        member = mtool.getAuthenticatedMember()
        fullname = member.getProperty("fullname")
        email = member.getProperty("email")

        if type_name in ["Image", "File"]:
            bc_url = "%s/@@file_view" % msg.absolute_url()
        else:
            bc_url = msg.absolute_url()

        body = translate(
            _(
                u"mail_body",
                default="${project_name} of the ${company_name} have a new comment posted. DO NOT REPLY TO THIS EMAIL. To comment on this message, visit:\n${msg_url}\n\n${user_name} <${user_email}> said:\n--------------------------------------------------------------------------\n${msg_body}\n\n${attachments}\n\n--\nDO NOT REPLY TO THIS EMAIL.\nTo comment on this message, visit:\n${msg_url}",
                mapping={
                    u"company_name": company.Title(),
                    u"project_name": project.Title(),
                    u"msg_url": bc_url,
                    u"user_name": fullname or member.getId(),
                    u"user_email": email,
                    u"msg_body": text,
                    u"attachments": attachments_msg,
                },
            ),
            context=self.request,
        )
        sm.sendMail(subject=subject, body=body)
        sm.subscribeAuthenticatedMember()
        return comment