-def edit_question(request, id):
- #question = get_object_or_404(Question, id=id)
- try:
- question = Question.objects.get(id=id)
- except:
- if slug:
- question = match_question_slug(slug)
- if question is not None:
- return HttpResponseRedirect(question.get_absolute_url())
+def convert_to_question(request, id):
+ user = request.user
+
+ node_type = request.GET.get('node_type', 'answer')
+ if node_type == 'comment':
+ node = get_object_or_404(Comment, id=id)
+ action_class = CommentToQuestionAction
+ else:
+ node = get_object_or_404(Answer, id=id)
+ action_class = AnswerToQuestionAction
+
+ if not user.can_convert_to_question(node):
+ return HttpResponseUnauthorized(request)