diff options
author | ashwinishinde | 2015-05-08 16:26:10 +0530 |
---|---|---|
committer | ashwinishinde | 2015-05-08 16:26:10 +0530 |
commit | b0351d0df6ae7fef2a461706542410a7e7ecea35 (patch) | |
tree | 39d94076b3156eca40fbf49560b90130005ba08f | |
parent | fd3d3d3c33d078cf497ca69937dc1a5402b4326c (diff) | |
download | FOSSEE-Forum-b0351d0df6ae7fef2a461706542410a7e7ecea35.tar.gz FOSSEE-Forum-b0351d0df6ae7fef2a461706542410a7e7ecea35.tar.bz2 FOSSEE-Forum-b0351d0df6ae7fef2a461706542410a7e7ecea35.zip |
Subject:Update notification count
Description:
1) update notification count after visit.
2) remove notification item from list after visted.
-rw-r--r-- | forums/views.py | 2 | ||||
-rw-r--r-- | static/website/templates/notifications.html | 17 | ||||
-rw-r--r-- | static/website/templates/notify.html | 4 | ||||
-rw-r--r-- | website/views.py | 21 |
4 files changed, 29 insertions, 15 deletions
diff --git a/forums/views.py b/forums/views.py index f602a55..f1f3096 100644 --- a/forums/views.py +++ b/forums/views.py @@ -157,7 +157,7 @@ def send_registration_confirmation(user): """.format( user.username, "http://fossee.in", - "http://localhost:8000/accounts/confirm/" + str(p.confirmation_code) + "/" + user.username + "http://forums.fossee.in/accounts/confirm/" + str(p.confirmation_code) + "/" + user.username ) email = EmailMultiAlternatives( subject, message, 'sysads@fossee.in', diff --git a/static/website/templates/notifications.html b/static/website/templates/notifications.html index aa3adce..35c30a3 100644 --- a/static/website/templates/notifications.html +++ b/static/website/templates/notifications.html @@ -28,6 +28,23 @@ } }); }); + + $(".rmc").click(function() { + $(this).parent(".notification").slideUp(); + + var notification_id = $(this).data("nid"); + $.ajax({ + url: "/ajax-notification-remove/", + type: "POST", + data: { + notification_id: notification_id + }, + success: function(data) { + console.log(data); + + } + }); + }); }); </script> {% endblock %} diff --git a/static/website/templates/notify.html b/static/website/templates/notify.html index 2ea55c5..9e048be 100644 --- a/static/website/templates/notify.html +++ b/static/website/templates/notify.html @@ -2,12 +2,12 @@ {% if notification.cid != 0 and notification.aid != 0 %} <small> - <a href="{% url 'website:get_question' answer.question.id %}#answer{{ answer.id }}">New <strong>Comment</strong> on "{{ question.title }}"</a> + <a class="rmc" data-nid="{{ notification.id }}" href="{% url 'website:get_question' answer.question.id %}#comment{{ answer.id }}">New <strong>Comment</strong> on <strong>"{{ question.title }}"</strong></a> </small> {% elif notification.cid == 0 %} - <a href="{% url 'website:get_question' answer.question.id %}#answer{{ answer.id }}"+ >New <strong>Answer</strong> on <strong>"{{ question.title }}"</strong></a> + <a class="rmc" data-nid="{{ notification.id }}" href="{% url 'website:get_question' answer.question.id %}#answer{{ answer.id }}"+ >New <strong>Answer</strong> on <strong>"{{ question.title }}"</strong></a> {% endif %} diff --git a/website/views.py b/website/views.py index de93b7f..516c7d4 100644 --- a/website/views.py +++ b/website/views.py @@ -140,19 +140,19 @@ def question_answer(request,qid): def answer_comment(request): if request.method == 'POST': answer_id = request.POST['answer_id']; - print answer_id answer = Answer.objects.get(pk=answer_id) answers = answer.question.answer_set.all() form = AnswerCommentForm(request.POST) if form.is_valid(): body = request.POST['body'] - print body comment = AnswerComment() comment.uid = request.user.id comment.answer = answer comment.body = body.encode('unicode_escape') + comment.save() - # notifying the answer owner + # notifying the answer owner + if answer.uid != request.user.id: notification = Notification() notification.uid = answer.uid @@ -241,7 +241,7 @@ def new_question(request): if request.method == 'POST': form = NewQuestionForm(request.POST) if form.is_valid(): - print "EEEEEEEEEEEEEEEE" + cleaned_data = form.cleaned_data question = Question() question.user = request.user @@ -251,8 +251,7 @@ def new_question(request): question.body = cleaned_data['body'].encode('unicode_escape') question.views= 1 question.save() - print "question" - print question.id + # Sending email when a new question is asked subject = 'New Forum Question' message = """ @@ -280,21 +279,20 @@ def new_question(request): return HttpResponseRedirect('/') else: - #fix dirty code + category = request.GET.get('category') form = NewQuestionForm(category=category) context['category'] = category context['form'] = form - print form.errors + context.update(csrf(request)) return render(request, 'website/templates/new-question.html', context) # Notification Section @login_required def user_questions(request, user_id): - print "user_id" - print user_id + marker = 0 if 'marker' in request.GET: marker = int(request.GET['marker']) @@ -309,8 +307,7 @@ def user_questions(request, user_id): 'total': total, 'marker': marker } - print "total" - print total + return render(request, 'website/templates/user-questions.html', context) return HttpResponse("go away") |