Commits

Anonymous committed c1556b4

Fixed question response view
fixed names of URL params

Comments (0)

Files changed (2)

gnocchi/ask/views.py

         form.save_m2m()
         return HttpResponseRedirect(obj.get_absolute_url())
 
-class QuestionRespond(generic.CreateView, SingleObjectMixin):
+class QuestionRespond(generic.CreateView):
     form_class = forms.AddResponseForm
-    model = models.Response
+    model = models.Question	# So that get_object looks for the right thing
     template_name = 'ask/response_form.html'
 
-    def get(self, *args, **kwargs):
-        self.object = self.get_object()
-        return super(QuestionRespond, self).get(*args, **kwargs)
-
-    def post(self, *args, **kwargs):
-        self.object = self.get_object()
-        return super(QuestionRespond, self).post(*args, **kwargs)
-
     def form_valid(self, form):
         obj = form.save(commit=False)
         obj.user = self.request.user
-        obj.question = self.object
+        obj.question = self.get_object()
         obj.save()
-        return HttpResponseRedirect(self.object.get_absolute_url())
+        return HttpResponseRedirect(obj.question.get_absolute_url())
 
     def get_context_data(self, **kwargs):
         data = super(QuestionRespond, self).get_context_data(**kwargs)
 }
 
 @permission_required('response.can_vote')
-def question_vote(request, question_id, response_id, direction, weight=1):
-    response = get_object_or_404(models.Response, pk=response_id,
+def question_vote(request, pk, response_id, direction, weight=1):
+    response = get_object_or_404(models.Response, pk=pk,
         question__id=question_id)
 
     weight = DIRECTION_WEIGHT[direction] * weight
     return HttpResponseRedirect(response.question.get_absolute_url())
 
 def response_accept(request, pk, response_id):
-    response = get_object_or_404(models.Response, pk=response_id,
-        question__id=pk)
+    response = get_object_or_404(models.Response, pk=pk, question__id=pk)
 
     if response.question.user == request.user:
         response.question.accepted = response
 from setuptools import setup, find_packages
 
 setup( name='gnocchi-ask',
-    version = '0.4',
+    version = '0.5',
     description = 'A simple StackOverflow/AskBot style application',
     author = 'Curtis Maloney',
     author_email = 'curtis@tinbrain.net',