Exemplo n.º 1
0
    def do_rating(self, user_from, rating, comment=None):
        self.check_user_can_rate(user_from)
        relation_type, user = self.target_rating(user_from)

        category = settings.RATINGS_STEP_FEEDBACK
        Rating.update(
            rating_context=self,
            rating_object=user,
            user=user_from,
            rating=rating,
            category=category,
            comment=comment,
        )
        signal_post_overall_rating_team_step_save.send(
            sender=self.__class__,
            team_step=self,
            user=user,
            relation_type=relation_type)
        return rating
Exemplo n.º 2
0
    def do_rating(self, user_from, rating, comment=None):
        from ..tasks import PostAnswerRatingTask

        act_action.send(
            user_from,
            verb=settings.FORUM_ACTION_RATING_POST,
            action_object=self)

        category = settings.RATINGS_ANSWER_ADVISOR
        Rating.update(
            rating_context=self,
            rating_object=self,
            user=user_from,
            rating=rating,
            category=category,
            comment=comment,
        )

        signal_post_overall_rating_answer_save.send(
            sender=self.__class__,
            answer=self)

        new_action_answer.send(
            sender=self.__class__,
            instance=self,
            action=settings.FORUM_ACTION_RATING_POST,
        )

        kwargs = {}
        kwargs['eta'] = increase_date(seconds=settings.FORUM_NEW_POST_DELAY)
        PostAnswerRatingTask().s(
            answer_pk=self.pk,
            rating=rating,
        ).apply_async(**kwargs)

        return rating