def reply(request, bits, context): """ If called without parameters will display a list of questions (via rendering page/content_type/interviews.interview/reply.html template). Can be also called as reply/PK/ which will then display a ReplyForm for the given question. Raises Http404 on any error or missing permissions. """ interview = context['object'] interviewees = interview.get_interviewees(request.user) context['interviewees'] = interviewees if not interviewees: # no permission raise Http404 if not bits: # list of all questions qset = interview.question_set.all() context.update(paginate_qset(request, qset)) return render_to_response( get_templates_from_placement('reply.html', context['placement']), context, context_instance=RequestContext(request) ) elif len(bits) != 1 or request.method != 'POST': # some bogus URL raise Http404() # no point in caching individual questions question = get_object_or_404( Question, pk=bits[0], interview=interview ) form = ReplyForm(interview, interviewees, question, request, request.POST) if form.is_valid(): form.save() # go back to the question list return HttpResponseRedirect('..') context['form'] = form context['question'] = question return render_to_response( get_templates_from_placement('answer_form.html', context['placement']), context, context_instance=RequestContext(request) )
def unanswered(request, context): """ Display unanswered questions via rendering page/content_type/interviews.interview/unanswered.html template. """ interview = context['object'] interviewees = interview.get_interviewees(request.user) context['interviewees'] = interviewees context['form'] = QuestionForm(request) # result pagination qset = interview.unanswered_questions() context.update(paginate_qset(request, qset)) return render_to_response(get_templates_from_placement( 'unanswered.html', context['placement']), context, context_instance=RequestContext(request))
def unanswered(request, context): """ Display unanswered questions via rendering page/content_type/interviews.interview/unanswered.html template. """ interview = context['object'] interviewees = interview.get_interviewees(request.user) context['interviewees'] = interviewees context['form'] = QuestionForm(request) # result pagination qset = interview.unanswered_questions() context.update(paginate_qset(request, qset)) return render_to_response( get_templates_from_placement('unanswered.html', context['placement']), context, context_instance=RequestContext(request) )
def list_questions(request, context): """ Displays a list of questions (via rendering page/content_type/interviews.interview/reply.html template). """ interview = context['object'] interviewees = interview.get_interviewees(request.user) context['interviewees'] = interviewees if not interviewees: # no permission raise Http404 # list of all questions qset = interview.question_set.all() context.update(paginate_qset(request, qset)) return render_to_response(get_templates_from_placement( 'reply.html', context['placement']), context, context_instance=RequestContext(request))
def list_questions(request, context): """ Displays a list of questions (via rendering page/content_type/interviews.interview/reply.html template). """ interview = context['object'] interviewees = interview.get_interviewees(request.user) context['interviewees'] = interviewees if not interviewees: # no permission raise Http404 # list of all questions qset = interview.question_set.all() context.update(paginate_qset(request, qset)) return render_to_response( get_templates_from_placement('reply.html', context['placement']), context, context_instance=RequestContext(request) )