def assert_is_visible_to(self, user): """raises QuestionHidden or AnswerHidden""" try: self.question.assert_is_visible_to(user) except exceptions.QuestionHidden: message = _('Sorry, the answer you are looking for is ' 'no longer available, because the parent ' 'question has been removed') raise exceptions.QuestionHidden(message) if self.deleted: message = _('Sorry, this answer has been ' 'removed and is no longer accessible') if user.is_anonymous(): raise exceptions.AnswerHidden(message) try: user.assert_can_see_deleted_post(self) except django_exceptions.PermissionDenied: raise exceptions.AnswerHidden(message)
def assert_is_visible_to(self, user): """raises QuestionHidden or AnswerHidden""" try: self.content_object.assert_is_visible_to(user) except exceptions.QuestionHidden: message = _('Sorry, the comment you are looking for is no ' 'longer accessible, because the parent question ' 'has been removed') raise exceptions.QuestionHidden(message) except exceptions.AnswerHidden: message = _('Sorry, the comment you are looking for is no ' 'longer accessible, because the parent answer ' 'has been removed') raise exceptions.AnswerHidden(message)