diff options
author | ashwinishinde | 2015-03-27 14:22:41 +0530 |
---|---|---|
committer | ashwinishinde | 2015-03-27 14:22:41 +0530 |
commit | a331b65a550e70424f0b799b1c90be0b0c688e85 (patch) | |
tree | 5c529283b2d2e98020dd6f884548cd695d7661c5 | |
parent | 8f1163e44643ba6bdfd8aa21d9afc6ba9a6b1639 (diff) | |
download | FOSSEE-Forum-a331b65a550e70424f0b799b1c90be0b0c688e85.tar.gz FOSSEE-Forum-a331b65a550e70424f0b799b1c90be0b0c688e85.tar.bz2 FOSSEE-Forum-a331b65a550e70424f0b799b1c90be0b0c688e85.zip |
Subject: user can get the Notications for answers and comments.
Description:
1) If user answers to the question then Notification to
that of that answer will send to intiator of question.
2) get Notication for add comment by another user.
-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 ...") |