diff options
-rw-r--r-- | website/forms.py | 2 | ||||
-rw-r--r-- | website/views.py | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/website/forms.py b/website/forms.py index 558d058..8b50a60 100644 --- a/website/forms.py +++ b/website/forms.py @@ -6,7 +6,7 @@ from django.db.models import Q class NewQuestionForm(forms.ModelForm): category = forms.ModelChoiceField(widget = forms.Select(attrs = {}), queryset = FossCategory.objects.order_by('name'), - empty_label = "Select a category", + empty_label = "Select a Foss category", required = True, error_messages = {'required':'Select a category.'}) diff --git a/website/views.py b/website/views.py index ca5b793..5d1b1c1 100644 --- a/website/views.py +++ b/website/views.py @@ -78,6 +78,7 @@ def question_answer(request,qid): question = get_object_or_404(Question, id=qid) answers = question.answer_set.all() answer = Answer() + answer.uid = request.user.id if form.is_valid(): cleaned_data = form.cleaned_data @@ -86,15 +87,17 @@ def question_answer(request,qid): answer.question = question answer.body = body.encode('unicode_escape') answer.save() + # if user_id of question not matches to user_id of answer that + # question , no if question.user_id != request.user.id: notification = Notification() - notification.uid = question.uid + notification.uid = question.user_id notification.pid = request.user.id notification.qid = qid notification.aid = answer.id notification.save() - user = User.objects.get(id=question.uid) + user = User.objects.get(id=question.user_id) # Sending email when an answer is posted subject = 'Question has been answered' message = """ @@ -325,11 +328,15 @@ def user_answers(request, user_id): @login_required def user_notifications(request, user_id): + print "user_id" + print user_id + print request.user.id if str(user_id) == str(request.user.id): notifications = Notification.objects.filter(uid=user_id).order_by('date_created').reverse() context = { 'notifications': notifications } + print notifications return render(request, 'website/templates/notifications.html', context) return HttpResponse("go away ...") |