Пример #1
0
    def addNewComment(self, uid, commentTitle, commentBody, commentId = None):
        """Adds a comment on the provided UID with given title, text and commenter user.
        """
        ids = component.getUtility(IIntIds, context = self.context)
        obj = ids.getObject(int(uid))
        discussion = IContentDiscussion(obj)

        commentText = cgi.escape(commentBody)

        comment = Comment(self.request.principal.id, commentText)

        tz = ITZInfo(self.request, None)
        if tz:
            comment.date = datetime.now(tz)
        else:
            comment.date = datetime.now(pytz.utc)

        comment = discussion.add(comment)

        return uid
Пример #2
0
    def reply(self, title, text, message):
        oid = message['In-Reply-To'].split('@', 1)[0].split('.', 1)[0][1:]

        try:
            post = getUtility(IIntIds).getObject(int(oid))
        except:
            return

        if checkPermission('zojax.AddComment', post):
            discussion = IContentDiscussion(post)

            interaction = queryInteraction()
            if interaction is not None and interaction.participations:
                request = interaction.participations[0]

                comment = Comment(request.principal.id, text.text)
                comment.date = datetime.now(ITZInfo(request, pytz.utc))

                comment = discussion.add(comment)
                event.notify(ObjectModifiedEvent(post))