예제 #1
0
    def test_last_participation_is_old(self):
        article = PublishedContentFactory(author_list=[self.user_author], type="ARTICLE")
        new_user = ProfileFactory().user
        reac = ContentReaction(author=self.user_author, position=1, related_content=article)
        reac.update_content("I will find you.")
        reac.save()
        article.last_note = reac
        article.save()

        self.assertFalse(last_participation_is_old(article, new_user))
        ContentRead(user=self.user_author, note=reac, content=article).save()
        reac = ContentReaction(author=new_user, position=2, related_content=article)
        reac.update_content("I will find you.")
        reac.save()
        article.last_note = reac
        article.save()
        ContentRead(user=new_user, note=reac, content=article).save()
        self.assertFalse(last_participation_is_old(article, new_user))
        self.assertTrue(last_participation_is_old(article, self.user_author))
예제 #2
0
def mark_read(content, user=None):
    """Mark the last tutorial note as read for the user.

    :param content: the content to mark
    :param user: user that read the content, if ``None`` will use currrent user
    """

    from zds.tutorialv2.models.database import ContentRead
    from zds.tutorialv2.models.database import ContentReaction

    if not user:
        user = get_current_user()

    if user and user.is_authenticated():
        if content.last_note is not None:
            ContentRead.objects.filter(content__pk=content.pk,
                                       user__pk=user.pk).delete()
            a = ContentRead(note=content.last_note, content=content, user=user)
            a.save()
            signals.content_read.send(sender=content.__class__,
                                      instance=content,
                                      user=user,
                                      target=ContentReaction)
예제 #3
0
파일: utils.py 프로젝트: josephcab/zds-site
def mark_read(content, user=None):
    """Mark the last tutorial note as read for the user.

    :param content: the content to mark
    :param user: user that read the content, if ``None`` will use currrent user
    """

    from zds.tutorialv2.models.database import ContentRead
    from zds.tutorialv2.models.database import ContentReaction

    if not user:
        user = get_current_user()

    if user and user.is_authenticated():
        if content.last_note is not None:
            ContentRead.objects.filter(
                content__pk=content.pk,
                user__pk=user.pk).delete()
            a = ContentRead(
                note=content.last_note,
                content=content,
                user=user)
            a.save()
            signals.content_read.send(sender=content.__class__, instance=content, user=user, target=ContentReaction)