コード例 #1
0
ファイル: notifications.py プロジェクト: Zojax/zojax.calendar
def CalendarEventModified(object, ev):
    """ sends emails when the event is modified """
    if IDraftedContent.providedBy(object):
        return

    principals = ()
    owner = IOwnership(object).owner.id
    attendees = object.attendees or None
    notification = component.getAdapter(object.__parent__, IEventNotification, 'event')

    if attendees:
        if owner not in attendees:
            principals += (owner, )
        principals += attendees

    if not attendees:
        principals += (owner, )

    #check subscribe
    for principal in principals:
        try:
            if not notification.isSubscribed(principal):
                notification.subscribe(principal)
        except SubscriptionException:
            pass

    # send notifications
    sendNotification('event', object, ev, principal={'any_of': principals})
コード例 #2
0
def commentAdded(comment, ev):
    """ sends emails when the comment is created """
    if not ICommentsNotificationsAware.providedBy(comment.content):
        return

    notification = getAdapter(comment.content, ICommentsNotification, 'comments')
    configlet = getUtility(IContentDiscussionConfig)

    if comment.isAvailable() and configlet.notificationsReceivers == 1:
        # check subscribe for current user
        try:
            if not notification.isSubscribedInParents():
                notification.subscribe()
        except SubscriptionException:
            pass

        # send notification
        sendNotification('comments', comment.content, comment)
    else:
        if configlet.notifyUsers:
            # subscribe
            for principal in configlet.notifyUsers:
                try:
                    if not notification.isSubscribedInParents(comment.content, principal):
                        notification.subscribe(principal)
                except SubscriptionException:
                    pass

            # send notification
            sendNotification('comments', comment.content, comment, principal={'any_of': configlet.notifyUsers})
コード例 #3
0
ファイル: notifications.py プロジェクト: Zojax/zojax.forum
def topicPublished(topic, ev):
    sendNotification('forum', topic, topic[TOPIC_FIRST_MESSAGE])
    notification = component.getAdapter(topic, ITopicNotification, 'forum.topic')
    try:
        if not notification.isSubscribed(IOwnership(topic).owner.id):
            notification.subscribe()
    except SubscriptionException:
        pass
    sendNotification('forum.topic', topic, topic[TOPIC_FIRST_MESSAGE])
コード例 #4
0
ファイル: notifications.py プロジェクト: Zojax/zojax.forum
def messageAdded(message, ev):
    if IDraftedContent.providedBy(message.__parent__):
        return
    sendNotification('forum', message.__parent__, message)
    notification = component.getAdapter(message.__parent__, ITopicNotification, 'forum.topic')
    try:
        if not notification.isSubscribed():
            notification.subscribe()
    except SubscriptionException:
        pass
    sendNotification('forum.topic', message.__parent__, message)
コード例 #5
0
ファイル: notifications.py プロジェクト: Zojax/zojax.calendar
def CalendarEventRemoved(object, ev):
    """ sends emails when the event is removed """
    if IDraftedContent.providedBy(object):
        return

    principals = ()
    owner = IOwnership(object).owner.id
    attendees = object.attendees or None
    notification = component.getAdapter(object.__parent__, IEventNotification, 'event')

    if attendees:
        if owner not in attendees:
            principals += (owner, )
        principals += attendees

    if not attendees:
        principals += (owner, )

    # send notifications
    sendNotification('event', object, ev, principal={'any_of': principals})
コード例 #6
0
    def uploadHandler(self, action):
        data, errors = self.extractData()

        if errors:
            IStatusMessage(self.request).add(self.formErrorMessage, 'warning')
        else:
            comment = data['comment']
            files = self.request.form[self.widgets['file'].name]
            if isinstance(files, FileUpload):
                files = [files]

            attachments = IAttachmentsExtension(self.context)
            chooser = INameChooser(attachments)

            attachs = []

            for file in files:
                if isinstance(file, FileUpload):
                    filename = os.path.split(file.filename)[1].lower().strip()

                    data = FileData(file, filename)
                    if data.mimeType in ('image/jpeg','image/gif','image/png'):
                        attach = Image(title=filename, description=comment)
                    else:
                        attach = File(title=filename, description=comment)

                    attach.data = data
                    event.notify(ObjectCreatedEvent(attach))

                    name = chooser.chooseName(filename, attach)
                    attachments[name] = attach

                    attachs.append(attach)

            sendNotification(
                'tasks', self.context, TaskAttachmentsInfo(comment, attachs))

            IStatusMessage(self.request).add(
                _('Attachments have been uploaded.'))
            self.redirect('.')
コード例 #7
0
def principalRegisteredHandler(ev):
    sendNotification('registration', getSite(), ev)
コード例 #8
0
def draftStatusChanged(object, ev):
    sendNotification("draft", object, ev)
コード例 #9
0
ファイル: notifications.py プロジェクト: Zojax/zojax.blogger
def commentAdded(post, ev):
    sendNotification('blog', post.__parent__, post, ev.comment)
コード例 #10
0
ファイル: notifications.py プロジェクト: Zojax/zojax.blogger
def blogPostPublished(post, ev):
    sendNotification('blog', post.__parent__, post)