Esempio n. 1
0
    def create_and_post(cls,
                        request,
                        author,
                        content,
                        quest,
                        uuid=None,
                        fact_metadata=None,
                        debug_content_id=None):
        from drawquest.apps.quests.models import Quest

        if not isinstance(quest, Quest):
            quest = Quest.objects.get(id=quest.id)

        was_first_quest = QuestComment.posting_in_first_quest(request.user)
        was_quest_of_the_day = cls.posting_would_complete_quest_of_the_day(
            author, quest)
        was_archived_quest = cls.posting_would_complete_archived_quest(
            author, quest)

        skip_moderation, curate = cls._auto_moderation(author)

        comment = super(QuestComment, cls).create_and_post(
            request,
            author,
            False,
            None,
            content,
            parent_comment=quest,
            fact_metadata=fact_metadata,
            posted_on_quest_of_the_day=quest.is_currently_scheduled(),
            curate=curate,
            skip_moderation=skip_moderation,
            debug_content_id=debug_content_id,
        )

        streak, _, __ = QuestComment.posting_would_reward_streak(author)
        if streak:
            economy.credit_streak(author, streak)

        if was_first_quest:
            economy.credit_first_quest(author)
        elif was_quest_of_the_day:
            economy.credit_quest_of_the_day_completion(author)
        elif was_archived_quest:
            economy.credit_archived_quest_completion(author)

        @bgwork.defer
        def followee_posted():
            Actions.followee_posted(author, comment)

            #TODO this should happen because of the above Actions.followee_posted
            for follower_id in author.redis.new_followers.zrange(0, -1):
                RealtimeChannel('user:{}:rt_tab_badges'.format(follower_id),
                                1).publish({'tab_badge_update': 'home'})

        return comment
Esempio n. 2
0
    def create_and_post(cls, request, author, content, quest, uuid=None, fact_metadata=None, debug_content_id=None):
        from drawquest.apps.quests.models import Quest

        if not isinstance(quest, Quest):
            quest = Quest.objects.get(id=quest.id)

        was_first_quest = QuestComment.posting_in_first_quest(request.user)
        was_quest_of_the_day = cls.posting_would_complete_quest_of_the_day(author, quest)
        was_archived_quest = cls.posting_would_complete_archived_quest(author, quest)

        skip_moderation, curate = cls._auto_moderation(author)

        comment = super(QuestComment, cls).create_and_post(
            request,
            author,
            False,
            None,
            content,
            parent_comment=quest,
            fact_metadata=fact_metadata,
            posted_on_quest_of_the_day=quest.is_currently_scheduled(),
            curate=curate,
            skip_moderation=skip_moderation,
            debug_content_id=debug_content_id,
        )

        streak, _, __ = QuestComment.posting_would_reward_streak(author)
        if streak:
            economy.credit_streak(author, streak)

        if was_first_quest:
            economy.credit_first_quest(author)
        elif was_quest_of_the_day:
            economy.credit_quest_of_the_day_completion(author)
        elif was_archived_quest:
            economy.credit_archived_quest_completion(author)

        @bgwork.defer
        def followee_posted():
            Actions.followee_posted(author, comment)

            # TODO this should happen because of the above Actions.followee_posted
            for follower_id in author.redis.new_followers.zrange(0, -1):
                RealtimeChannel("user:{}:rt_tab_badges".format(follower_id), 1).publish({"tab_badge_update": "home"})

        return comment
Esempio n. 3
0
    def create_and_post(cls,
                        request,
                        author,
                        content,
                        quest,
                        fact_metadata=None):
        from drawquest.apps.quests.models import Quest

        if not isinstance(quest, Quest):
            quest = Quest.objects.get(id=quest.id)

        was_first_quest = QuestComment.posting_in_first_quest(request.user)
        was_quest_of_the_day = cls.posting_would_complete_quest_of_the_day(
            author, quest)
        was_archived_quest = cls.posting_would_complete_archived_quest(
            author, quest)

        comment = super(QuestComment, cls).create_and_post(
            request,
            author,
            False,
            None,
            content,
            parent_comment=quest,
            fact_metadata=fact_metadata,
            posted_on_quest_of_the_day=quest.is_currently_scheduled(),
        )

        streak = QuestComment.posting_would_reward_streak(author, quest)
        if streak:
            economy.credit_streak(author, streak)

        if was_first_quest:
            economy.credit_first_quest(author)
        elif was_quest_of_the_day:
            economy.credit_quest_of_the_day_completion(author)
        elif was_archived_quest:
            economy.credit_archived_quest_completion(author)

        @bgwork.defer
        def followee_posted():
            Actions.followee_posted(author, comment)

        return comment
Esempio n. 4
0
    def create_and_post(cls, request, author, content, quest, fact_metadata=None):
        from drawquest.apps.quests.models import Quest

        if not isinstance(quest, Quest):
            quest = Quest.objects.get(id=quest.id)

        was_first_quest = QuestComment.posting_in_first_quest(request.user)
        was_quest_of_the_day = cls.posting_would_complete_quest_of_the_day(author, quest)
        was_archived_quest = cls.posting_would_complete_archived_quest(author, quest)

        comment = super(QuestComment, cls).create_and_post(
            request,
            author,
            False,
            None,
            content,
            parent_comment=quest,
            fact_metadata=fact_metadata,
            posted_on_quest_of_the_day=quest.is_currently_scheduled(),
        )

        streak = QuestComment.posting_would_reward_streak(author, quest)
        if streak:
            economy.credit_streak(author, streak)

        if was_first_quest:
            economy.credit_first_quest(author)
        elif was_quest_of_the_day:
            economy.credit_quest_of_the_day_completion(author)
        elif was_archived_quest:
            economy.credit_archived_quest_completion(author)

        @bgwork.defer
        def followee_posted():
            Actions.followee_posted(author, comment)

        return comment