1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Add notification at info-bar, and fix bug in visiting register/login page when user is already logged in.

This commit is contained in:
xiez
2012-06-04 21:27:32 +08:00
parent 28dbc2ad73
commit f9c72b57a4
17 changed files with 286 additions and 5 deletions

View File

@@ -1,5 +1,10 @@
from django.core.cache import cache
from seaserv import get_binding_peerids
from seahub.notifications.models import Notification
from seahub.notifications.utils import refresh_cache
class UseridMiddleware(object):
"""Store ccnet user ids in request.user.userid_list"""
@@ -16,3 +21,30 @@ class UseridMiddleware(object):
def process_response(self, request, response):
return response
class InfobarMiddleware(object):
"""Query info bar close status, and store into reqeust."""
def get_from_db(self):
ret = Notification.objects.all().filter(primary=1)
refresh_cache()
return ret
def process_request(self, request):
topinfo_close = request.COOKIES.get('topinfo', '')
cur_note = cache.get('CUR_TOPINFO') if cache.get('CUR_TOPINFO') else \
self.get_from_db()
if not cur_note:
request.cur_note = None
else:
if str(cur_note[0].id) in topinfo_close.split(','):
request.cur_note = None
else:
request.cur_note = cur_note[0]
return None
def process_response(self, request, response):
return response