def test_solution_notification_deleted(self, get_current): """Calling QuestionSolvedEvent.fire() should not query the questions_question table. This test attempts to simulate the replication lag presumed to cause bug 585029. """ get_current.return_value.domain = 'testserver' a = answer(save=True) q = a.question q.solution = a q.save() a_user = a.creator QuestionSolvedEvent.notify(a_user, q) event = QuestionSolvedEvent(a) # Delete the question, pretend it hasn't been replicated yet Question.objects.get(pk=q.pk).delete() event.fire(exclude=q.creator) # There should be a reply notification and a solved notification. eq_(2, len(mail.outbox)) eq_('Solution found to Firefox Help question', mail.outbox[1].subject)
def set_solution(self, answer, solver): """ Sets the solution, and fires any needed events. Does not check permission of the user making the change. """ # Avoid circular import from kitsune.questions.events import QuestionSolvedEvent self.solution = answer self.save() self.add_metadata(solver_id=str(solver.id)) statsd.incr('questions.solution') QuestionSolvedEvent(answer).fire(exclude=self.creator) SolutionAction(user=answer.creator, day=answer.created).save()
def set_solution(self, answer, solver): """ Sets the solution, and fires any needed events. Does not check permission of the user making the change. """ # Avoid circular import from kitsune.questions.events import QuestionSolvedEvent self.solution = answer self.save() self.add_metadata(solver_id=str(solver.id)) statsd.incr('questions.solution') QuestionSolvedEvent(answer).fire(exclude=self.creator) actstream.action.send( solver, verb='marked as a solution', action_object=answer, target=self)