Ejemplo n.º 1
0
    def post_save(cls, sender, instance, created, **kwargs):
        if created:
            # TODO 添加通知
            from apps.account.models import Focus
            instance.tag.update_date = now()
            instance.tag.save()

            for focus in Focus.get_focus_by_content_object(instance.tag).exclude(user=instance.question.user):
                notify.send(get_model(settings.AUTH_USER_MODEL).objects.get(id=settings.NOTIFICATION_USER),
                            recipient=focus.user,
                            verb=u'你关注的标签[{tag}]有新的问题'.format(tag=instance.tag.title),
                            action_object=instance,
                            description=instance.question.get_markdown()
                )
Ejemplo n.º 2
0
    def post_save(cls, sender, instance, created, **kwargs):
        if created:
            # TODO 添加通知
            from apps.account.models import Focus
            instance.tag.update_date = now()
            instance.tag.save()

            for focus in Focus.get_focus_by_content_object(
                    instance.tag).exclude(user=instance.question.user):
                notify.send(
                    get_model(settings.AUTH_USER_MODEL).objects.get(
                        id=settings.NOTIFICATION_USER),
                    recipient=focus.user,
                    verb=u'你关注的标签[{tag}]有新的问题'.format(tag=instance.tag.title),
                    action_object=instance,
                    description=instance.question.get_markdown())
Ejemplo n.º 3
0
 def post_save(cls, sender, instance, created, **kwargs):
     if created:
         instance.article.update_date = now()
         instance.article.save()
         #TODO 添加通知
         sender = get_model(settings.AUTH_USER_MODEL).objects.get(id=settings.NOTIFICATION_USER)
         notify.send(sender,
                     recipient=instance.article.user,
                     verb=u'你发起的文章[{article}]有新的回复'.format(article=instance.article.title),
                     action_object=instance,
                     description=instance.get_markdown()
         )
         from apps.account.models import Focus
         for focus in Focus.get_focus_by_content_object(instance.article).exclude(user__in=[instance.user, instance.article.user]):
             print focus.user
             notify.send(sender,
                         recipient=focus.user,
                         verb=u'你关注的文章[{article}]有新的回复'.format(article=instance.article.title),
                         action_object=instance,
                         description=instance.get_markdown()
             )
Ejemplo n.º 4
0
    def post_save(cls, sender, instance, created, **kwargs):
        if created:
            instance.question.update_status()
            # TODO 添加通知
            from apps.account.models import Focus
            sender = get_model(settings.AUTH_USER_MODEL).objects.get(id=settings.NOTIFICATION_USER)

            notify.send(sender,
                        recipient=instance.question.user,
                        verb=u'你发起的问题[{question}]有新的回答'.format(question=instance.question.title),
                        action_object=instance,
                        description=instance.get_markdown()
            )

            for focus in Focus.get_focus_by_content_object(instance.question).exclude(
                    user__in=[instance.user.id, instance.question.user.id]):
                notify.send(sender,
                            recipient=focus.user,
                            verb=u'你关注的问题[{question}]有新的回答'.format(question=instance.question.title),
                            action_object=instance,
                            description=instance.get_markdown()
                )
Ejemplo n.º 5
0
    def post_save(cls, sender, instance, created, **kwargs):
        if created:
            instance.question.update_status()
            # TODO 添加通知
            from apps.account.models import Focus
            sender = get_model(settings.AUTH_USER_MODEL).objects.get(
                id=settings.NOTIFICATION_USER)

            notify.send(sender,
                        recipient=instance.question.user,
                        verb=u'你发起的问题[{question}]有新的回答'.format(
                            question=instance.question.title),
                        action_object=instance,
                        description=instance.get_markdown())

            for focus in Focus.get_focus_by_content_object(
                    instance.question
            ).exclude(user__in=[instance.user.id, instance.question.user.id]):
                notify.send(sender,
                            recipient=focus.user,
                            verb=u'你关注的问题[{question}]有新的回答'.format(
                                question=instance.question.title),
                            action_object=instance,
                            description=instance.get_markdown())