def get(self, request, question_uuid=None, slug=None): if question_uuid is not None: try: question = Question.get(question_uuid) except (DoesNotExist, Question.DoesNotExist): return redirect('404_Error') if question.owner_username != request.user.username \ and self.template_name == "questions/edit.html": return redirect('401_Error') return render( request, self.template_name, { 'sort_by': 'uuid', 'authors': question.get_conversation_authors(), 'solution_placeholder': render_to_string("solutions/placeholder.html"), 'question': QuestionSerializerNeo(question, context={ "request": request }).data, }) else: return render( request, self.template_name, { 'question_placeholder': render_to_string('questions/placeholder.html') })
def get_question(self, obj): from sb_questions.neo_models import Question from sb_questions.serializers import QuestionSerializerNeo request, expand, _, relations, expedite = gather_request_data( self.context, expedite_param=self.context.get('expedite_param', None), expand_param=self.context.get('expand_param', None)) question = Question.get(object_uuid=obj.parent_id) if expand: return QuestionSerializerNeo(question).data return reverse('question-detail', kwargs={'object_uuid': question.object_uuid}, request=self.context.get('request', None))
def question_redirect_page(request, question_uuid): """ This is the view that displays a single question with all solutions, comments, references and tags. :param question_uuid: :param request: :return: """ return redirect("question_detail_page", question_uuid=question_uuid, slug=slugify( Question.get(object_uuid=question_uuid).title), permanent=True)