Exemple #1
0
    def update_status(self, value):
        """ Update status and save it """

        old_status = self.status
        if value == const.ACTION_STATUS_VICTORY:
            self.victory = True
            self.save()
        elif value == const.ACTION_STATUS_CLOSED:
            self.thread.closed = True
            self.thread.save()
        elif value == const.ACTION_STATUS_DELETED:
            self.question.deleted = True
            self.question.save()
        elif value == const.ACTION_STATUS_DRAFT:
            log.warning("Setting of DRAFT status, this shouldn't be done")
            self.question.score = 0
            self._threshold = None
            self.question.save()
            self.save()
        elif value == const.ACTION_STATUS_READY:
            log.warning("Setting of READY status, this should be done only by bot")
            assert self.threshold #Force threshold computation
        else:
            raise ValueError("Invalid status %s for action %s" % (value, self))

        post_action_status_update.send(sender=self,
            old_status=old_status
        )
Exemple #2
0
    def test_notify_action_get_level_step(self):
        """ """
        # add voter to action voters
        self.test_add_vote_to_ready_action()
        # change status
        self._action.compute_threshold()
        self._action.update_status(const.ACTION_STATUS_READY)

        #sending action status update signal
        post_action_status_update.send(sender=self._action, 
            old_status=const.ACTION_STATUS_READY
        )

        notice_type = NoticeType.objects.get(label="joined_action_get_level_step")
        try:
            notice_obj = Notice.objects.get(recipient=self._author, 
                notice_type=notice_type
            )
        except Notice.DoesNotExist as e:
            notice_obj = False

        self.assertTrue(notice_obj)