summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/website/templates/filter.html9
-rw-r--r--static/website/templates/new-question.html7
-rw-r--r--website/views.py23
3 files changed, 20 insertions, 19 deletions
diff --git a/static/website/templates/filter.html b/static/website/templates/filter.html
index f04f226..c64f68c 100644
--- a/static/website/templates/filter.html
+++ b/static/website/templates/filter.html
@@ -5,7 +5,11 @@
{% if questions %}
<h5>
These are the similar questions in:
- {% if category %}
+
+
+
+ {% for category in categories %}
+ {% if category %}
{{ category }}
{% endif %}
{% if tutorial %}
@@ -20,7 +24,8 @@
<b> &gt; </b>
{{ second_range }} sec
{% endif %}
- <a class="btn btn-xs btn-success pull-right" href="{% url 'website:new_question' %}?category={{ category|urlencode }}">Ask a new question.</a>
+ <a class="btn btn-xs btn-success pull-right" href="{% url 'website:new_question' %}?category={{ category.id |urlencode }}">Ask a new question.</a>
+ {% endfor %}
</h5>
<br>
<div class="clearfix"></div>
diff --git a/static/website/templates/new-question.html b/static/website/templates/new-question.html
index af0e34b..cbc6063 100644
--- a/static/website/templates/new-question.html
+++ b/static/website/templates/new-question.html
@@ -19,13 +19,6 @@
{% render_field form.category class+="form-control category"%}
</div>
- <!--<div class="col-lg-3 col-md-3 col-sm-3">
- {% if category %}
- {% render_field form.tutorial class+="form-control" %}
- {% else %}
- {% render_field form.tutorial class+="form-control" %}
- {% endif %}
- </div>-->
<div class="col-lg-2 col-md-2 col-sm-2">
<small><strong>
<a id="similar-link" data-toggle="modal" data-target="#similarModal" href="#">
diff --git a/website/views.py b/website/views.py
index 603a4c7..f80ee13 100644
--- a/website/views.py
+++ b/website/views.py
@@ -1,5 +1,4 @@
import re
-
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404,render_to_response
from django.core.context_processors import csrf
@@ -213,6 +212,7 @@ def answer_comment(request):
def filter(request, category=None, tutorial=None, minute_range=None, second_range=None):
+ dict_context = {}
context = {
'category': category,
'tutorial': tutorial,
@@ -231,9 +231,15 @@ def filter(request, category=None, tutorial=None, minute_range=None, second_ran
if 'qid' in request.GET:
context['qid'] = int(request.GET['qid'])
-
- context['questions'] = questions
- return render(request, 'website/templates/filter.html', context)
+
+ categories = FossCategory.objects.filter(name=category)
+
+ dict_context = {
+ 'questions':questions,
+ 'categories': categories
+ }
+
+ return render(request, 'website/templates/filter.html', dict_context)
@login_required
def new_question(request):
@@ -246,13 +252,12 @@ def new_question(request):
question = Question()
question.user = request.user
question.category = cleaned_data['category']
-
question.title = cleaned_data['title']
question.body = cleaned_data['body'].encode('unicode_escape')
question.views= 1
question.save()
- # Sending email when a new question is asked
+ #Sending email when a new question is asked
subject = 'New Forum Question'
message = """
The following new question has been posted in the FOSSEE Forum: <br>
@@ -271,11 +276,9 @@ def new_question(request):
['team@fossee.in'],
headers={"Content-type":"text/html;charset=iso-8859-1"}
)
- print message
- print "****************"
+
email.attach_alternative(message, "text/html")
email.send(fail_silently=True)
- # End of email send
return HttpResponseRedirect('/')
else:
@@ -341,7 +344,7 @@ def user_notifications(request, user_id):
context = {
'notifications': notifications
}
- print notifications
+
return render(request, 'website/templates/notifications.html', context)
return HttpResponse("go away ...")