From c5be7a4062c3ea86c23ccd41c294fb299cc63f8d Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 20 Aug 2012 15:24:43 +0800 Subject: [PATCH] modified cookie set --- notifications/urls.py | 1 - notifications/views.py | 12 ------------ templates/base.html | 9 ++++----- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/notifications/urls.py b/notifications/urls.py index 7d5ff43812..52c0f59e80 100644 --- a/notifications/urls.py +++ b/notifications/urls.py @@ -5,7 +5,6 @@ urlpatterns = patterns('notifications.views', url(r'^add/$', 'notification_add', name='notification_add'), url(r'^delete/(?P[\d]+)/$', 'notification_delete', name='notification_delete'), url(r'^set-primary/(?P[\d]+)/$', 'set_primary', name='set_primary'), - url(r'^close/(?P[\d]+)/$', 'notification_close', name='notification_close'), ) diff --git a/notifications/views.py b/notifications/views.py index a5792fa120..a564ab19fb 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -9,18 +9,6 @@ from auth.decorators import login_required from seahub.notifications.models import Notification, NotificationForm from seahub.notifications.utils import refresh_cache -@login_required -def notification_close(request, note_id): - note_id += ',' - topinfo_close = request.COOKIES.get('topinfo', '') - topinfo_close += note_id - - next = request.GET.get('next', '/') - res = HttpResponseRedirect(next) - res.set_cookie("topinfo", topinfo_close, max_age=14*24*60*60) - - return res - @login_required def notification_list(request): if not request.user.is_staff: diff --git a/templates/base.html b/templates/base.html index 64f0458613..ee7cac314e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -136,19 +136,18 @@ $('#info-bar .close').click(function() { $('#info-bar').addClass('hide'); if (navigator.cookieEnabled) { var cookies = document.cookie.split('; '), - topinfo_exist = false; + topinfo_exist = false, + topinfo_new_value = $(this).attr('data') + ',' + '; max-age=' + 14*24*60*60 + '; path=' + '{{ SITE_ROOT }}'; for (var i = 0, len = cookies.length; i < len; i++) { if (cookies[i].split('=')[0] == 'topinfo') { - cookies[i] += $(this).attr('data') + ','; topinfo_exist = true; - document.cookie = cookies.join('; '); + document.cookie = 'topinfo=' + cookies[i].split('=')[1] + topinfo_new_value; break; } } if (!topinfo_exist) { - document.cookie += '; topinfo=' + $(this).attr('data') + ','; + document.cookie = 'topinfo=' + topinfo_new_value; } - document.cookie += '; max-age=' + 14*24*60*60; } }); {% endif %}