コード例 #1
0
class PingSubscription(AnswerSubscription, MultipleNotificationsMixin):
    """
    Subscription to ping of a user
    """
    module = _('Ping')
    objects = SubscriptionManager()

    def __str__(self):
        return _('<Abonnement du membre "{0}" aux mentions>').format(self.profile, self.object_id)

    @staticmethod
    def mark_inaccessible_ping_as_read_for_topic(topic):
        for post in Post.objects.filter(topic=topic):
            for notification in Notification.objects.filter(content_type__pk=ContentType.objects.get_for_model(post).pk,
                                                            object_id=post.pk):
                if not topic.forum.can_read(notification.subscription.user):
                    notification.is_read = True
                    notification.is_dead = True
                    notification.save(update_fields=['is_read'])

    def get_notification_title(self, answer):
        assert hasattr(answer, 'author')
        assert hasattr(answer, 'get_notification_title')

        return _('{0} vous a mentionné sur {1}.').format(answer.author, answer.get_notification_title())
コード例 #2
0
class ContentReactionAnswerSubscription(AnswerSubscription, SingleNotificationMixin):
    """
    Subscription to new answer in a publishable content.
    """
    module = _('Contenu')
    objects = SubscriptionManager()

    def __str__(self):
        return _('<Abonnement du membre "{0}" aux réponses du contenu #{1}>')\
            .format(self.user.username, self.object_id)
コード例 #3
0
class PrivateTopicAnswerSubscription(AnswerSubscription, SingleNotificationMixin):
    """
    Subscription to new answer in a private topic.
    """
    module = _('Message privé')
    objects = SubscriptionManager()

    def __str__(self):
        return _('<Abonnement du membre "{0}" aux réponses à la conversation privée #{1}>')\
            .format(self.user.username, self.object_id)
コード例 #4
0
ファイル: models.py プロジェクト: BertrandD/zds-site
class PingSubscription(AnswerSubscription, MultipleNotificationsMixin):
    """
    Subscription to ping of a user
    """
    module = _(u'Ping')
    objects = SubscriptionManager()

    def __str__(self):
        return _(u'<Abonnement du membre "{0}" aux mentions>').format(self.profile, self.object_id)

    def get_notification_title(self, answer):
        assert hasattr(answer, 'author')
        assert hasattr(answer, 'get_notification_title')

        return _(u'{0} vous a mentionné sur {1}.').format(answer.author, answer.get_notification_title())
コード例 #5
0
class NewPublicationSubscription(Subscription, MultipleNotificationsMixin):
    """
    Subscription to new publications from a user.
    """
    module = _('Contenu')
    objects = SubscriptionManager()

    def __str__(self):
        return _('<Abonnement du membre "{0}" aux nouvelles publications de l\'utilisateur #{1}>') \
            .format(self.user.username, self.object_id)

    def get_notification_url(self, content):
        return content.get_absolute_url_online()

    def get_notification_title(self, content):
        return content.title
コード例 #6
0
ファイル: models.py プロジェクト: banco29510/zds-site
class NewTopicSubscription(Subscription, MultipleNotificationsMixin):
    """
    Subscription to new topics in a forum or with a tag
    """
    module = _(u'Forum')
    objects = SubscriptionManager()

    def __unicode__(self):
        return _(u'<Abonnement du membre "{0}" aux nouveaux sujets du {1} #{2}>')\
            .format(self.user.username, self.content_type, self.object_id)

    def get_notification_url(self, topic):
        return topic.get_absolute_url()

    def get_notification_title(self, topic):
        return topic.title