Exemplo n.º 1
0
 def email_subscriber(self, user):
     """ Email subscribers to the listing this post is part of """
     if not self.published:
         return None
     if user != self.author:
         subject = '[seabirds.net] New %s post "%s"' % (self.listing, self.title)
         template_data = { 'user': user, 'post': self }
         return generate_email(user, subject, template_data, self.text_template, self.html_template)
Exemplo n.º 2
0
 def email_author_about_comment(self, user):
     if self.is_removed:
         return None
     assert user == self.content_object.author
     # Prevent sending a notification when a user comments on
     # something they authored.
     if self.user == self.content_object.author:
         return None
     title = self.content_object.title
     subject = '[seabirds.net] New comment on your %s "%s"' % (
             self.content_type.model, title)
     template_data = {'user': user, 'comment': self}
     return generate_email(user, subject, template_data, self.template, self.html_template)
Exemplo n.º 3
0
    def email_commenters(self, user):
        # TODO: If there is an op out for a conversation, or being emailed
        # about comments, then it could be checked here

        if self.is_removed:
            return None
        # Do not email the commenter, or the author (the author is notified
        # by `email_author_about_comment`
        if user == self.user or user == self.content_object.author:
            return None
        title = self.content_object.title
        subject = '[seabirds.net] New comment on %s "%s"' % (
                self.content_type.model, title)
        template_data = {'user': user, 'comment': self}
        return generate_email(user, subject, template_data, self.template, self.html_template)
Exemplo n.º 4
0
 def email_moderator(self, user):
     """ Email moderator when new post is made by a non-staff member
     
     This is to allow for the message to edited if necessary before they
     get sent to all subscribers. The moderator only gets emailed once it
     looks like there are no further changes from the author (i.e. after
     there are no new edits for a given time).
     """
     if self.listing.can_user_moderate(user):
         subject = '[seabirds.net] New post by %s' % self.author
         editable_until = (self.date_updated +
                 datetime.timedelta(seconds=settings.PIGEONPOST_DELAYS['cms.Post']['subscriber']))
         # If it's in the past, don't show it
         if editable_until < datetime.datetime.now():
             editable_until = None
         template_data = { 'user': user, 'post': self, 'is_moderator': True,
                 'editable_until': editable_until}
         return generate_email(user, subject, template_data, self.text_template, self.html_template)
Exemplo n.º 5
0
    def email_author(self, user):
        """ Email author when they make a new post
        
        This lets the author know they have a while to make edits before
        it's checked by a moderator and sent out to subscibers.

        TODO: Think about if we really need this, since the user will
        already be aware they created it (and presumedly see the ability
        to edit it)
        """
        if user == self.author:
            subject = '[seabirds.net] Your new post "%s"' % self.title
            editable_until = (self.date_updated +
                    datetime.timedelta(seconds=settings.PIGEONPOST_DELAYS['cms.Post']['subscriber']))
            # If it's in the past, don't show it
            if editable_until < datetime.datetime.now():
                editable_until = None
            template_data = { 'user': user, 'post': self, 'editable_until': editable_until }
            return generate_email(user, subject, template_data, self.text_template, self.html_template)