summaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
Diffstat (limited to 'website')
-rw-r--r--website/forms.py4
-rw-r--r--website/urls.py2
-rw-r--r--website/views.py19
3 files changed, 20 insertions, 5 deletions
diff --git a/website/forms.py b/website/forms.py
index d6f281c..6db930a 100644
--- a/website/forms.py
+++ b/website/forms.py
@@ -27,4 +27,6 @@ class NewQuestionForm(forms.ModelForm):
class AnswerQuesitionForm(forms.Form):
question = forms.IntegerField(widget=forms.HiddenInput())
- body = forms.CharField(widget=forms.Textarea())
+ body = forms.CharField(widget=forms.Textarea(),
+ required = True
+ )
diff --git a/website/urls.py b/website/urls.py
index a61892a..33ad485 100644
--- a/website/urls.py
+++ b/website/urls.py
@@ -5,7 +5,7 @@ urlpatterns = patterns('',
url(r'^questions/$', 'website.views.questions', name='questions'),
url(r'^question/(?P<question_id>\d+)/$', 'website.views.get_question', name='get_question'),
url(r'^question/(?P<question_id>\d+)/(?P<pretty_url>.+)/$', 'website.views.get_question', name='get_question'),
- url(r'^question-answer/$', 'website.views.question_answer', name='question_answer'),
+ url(r'^question-answer/(?P<qid>\d+)/$', 'website.views.question_answer', name='question_answer'),
url(r'^answer-comment/$', 'website.views.answer_comment', name='answer_comment'),
url(r'^filter/(?P<category>[^/]+)/$', 'website.views.filter', name='filter'),
url(r'^filter/(?P<category>[^/]+)/(?P<tutorial>[^/]+)/$', 'website.views.filter', name='filter'),
diff --git a/website/views.py b/website/views.py
index 9b413e5..542f688 100644
--- a/website/views.py
+++ b/website/views.py
@@ -65,8 +65,11 @@ def get_question(request, question_id=None, pretty_url=None):
return render(request, 'website/templates/get-question.html', context)
@login_required
-def question_answer(request):
+def question_answer(request,qid):
+ print qid
+ context = {}
if request.method == 'POST':
+
form = AnswerQuesitionForm(request.POST)
if form.is_valid():
cleaned_data = form.cleaned_data
@@ -110,11 +113,21 @@ def question_answer(request):
email.attach_alternative(message, "text/html")
email.send(fail_silently=True)
# End of email send
- return HttpResponseRedirect('/question/'+ str(qid) + "#answer" + str(answer.id))
- return HttpResponseRedirect('/')
+ return HttpResponseRedirect('/question/'+ str(qid) + "#answer" + str(answer.id))
+ else:
+ form = AnswerQuesitionForm()
+ context = {
+ 'form': form
+ }
+ #print form
+
+ return HttpResponseRedirect('/question/'+ str(qid))
+
+
@login_required
def answer_comment(request):
+
if request.method == 'POST':
answer_id = request.POST['answer_id'];
body = request.POST['body']