diff --git a/qa/models.py b/qa/models.py index c6e5591..8665fc6 100644 --- a/qa/models.py +++ b/qa/models.py @@ -39,7 +39,7 @@ class Question(models.Model): closed = models.BooleanField(default=False) def __str__(self): - return self.question_text + return self.title class Answer(models.Model): diff --git a/qa/templates/qa/add.html b/qa/templates/qa/add.html index fc64a0a..dff604c 100644 --- a/qa/templates/qa/add.html +++ b/qa/templates/qa/add.html @@ -15,7 +15,7 @@
{% csrf_token %} -

+

{% markdown_editor "#ans" %} {% markdown_media %} diff --git a/qa/templates/qa/answer.html b/qa/templates/qa/answer.html index 96f8ba4..e3114b6 100644 --- a/qa/templates/qa/answer.html +++ b/qa/templates/qa/answer.html @@ -7,7 +7,7 @@ {% if message %} Enter a valid Answer! {% endif %} -

Answering Question : {{ question.question_text }}

+

Answering Question : {{ question.title }}

{% if user.is_authenticated %} diff --git a/qa/templates/qa/detail.html b/qa/templates/qa/detail.html index 12355fc..ad8ec98 100644 --- a/qa/templates/qa/detail.html +++ b/qa/templates/qa/detail.html @@ -79,7 +79,7 @@
Posted by {{ question.user_data.user.username }}, {{ question.pub_date }} -

Q: {{ question.question_text }}

+

Q: {{ question.title }}

{{ question.description }}

{% if user.is_authenticated %} diff --git a/qa/templates/qa/index.html b/qa/templates/qa/index.html index 82882a4..23e044b 100644 --- a/qa/templates/qa/index.html +++ b/qa/templates/qa/index.html @@ -33,7 +33,8 @@

{{ question.answer_set.count }}
Answers
{{ question.views }}
Views

- {% if question.reward %}{% endif %} {{ question.question_text }} + {% if question.reward %}{% endif %} +

{{ question.title }}


{% for tag in question.tags.all %} {{ tag.slug }} @@ -72,7 +73,7 @@
{{ question.answer_set.count }}
Answers
{{ question.views }}
Views

- {% if question.answer_set.count %}{% endif %} {{ question.question_text }} + {% if question.answer_set.count %}{% endif %} {{ question.title }}
{% for tag in question.tags.all %} {{ tag.slug }} @@ -95,7 +96,7 @@

{{ question.answer_set.count }}
Answers
{{ question.views }}
Views

- {% if question.answer_set.count %}{% endif %} {{ question.question_text }} + {% if question.answer_set.count %}{% endif %} {{ question.title }}
Earn {{ question.reward }} points {% for tag in question.tags.all %} @@ -145,7 +146,7 @@

Unanswered Questions

diff --git a/qa/views.py b/qa/views.py index 727dd83..7baf6b2 100644 --- a/qa/views.py +++ b/qa/views.py @@ -14,7 +14,7 @@ def search(request): if request.method == 'POST': word = request.POST['word'] - latest_question_list = Question.objects.filter(question_text__contains=word) + latest_question_list = Question.objects.filter(title__contains=word) paginator = Paginator(latest_question_list, 10) page = request.GET.get('page') try: @@ -112,21 +112,19 @@ def add(request): return HttpResponseRedirect("/login/") if request.method == 'POST': - question_text = request.POST['question'] + question_title = request.POST['title'] question_description = request.POST['description'] tags_text = request.POST['tags'] user_id = request.POST['user'] user = get_user_model().objects.get(id=user_id) - if question_text.strip() == '': + if question_title.strip() == '': return render(request, 'qa/add.html', {'message': 'Empty'}) question = Question() - question.question_text = question_text + question.title = question_title question.description = question_description question.user = user - question.save() - tags = tags_text.split(',') for tag in tags: try: @@ -138,6 +136,7 @@ def add(request): tag_object.save() question.tags.add(tag_object) + question.save() #send_mail('QA: Your Question has been Posted.', 'Thank you for posting the question, '+question_text+'. We will notify you once someone posts an answer.', 'admin@test.com', [request.user.email], fail_silently=False) return HttpResponseRedirect('/')