##// END OF EJS Templates
Download attachments to tmp file, not into memory
Download attachments to tmp file, not into memory

File last commit:

r1090:a66d091f default
r1394:f7e9602f default
Show More
notifications.py
46 lines | 1.5 KiB | text/x-python | PythonLexer
neko259
User notifications (BB-59)
r990 from django.shortcuts import render
neko259
Refactored views
r1090
neko259
User notifications (BB-59)
r990 from boards.abstracts.paginator import get_paginator
from boards.abstracts.settingsmanager import get_settings_manager, \
SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID
from boards.models.user import Notification
from boards.views.base import BaseBoardView
neko259
Refactored views
r1090 DEFAULT_PAGE = '1'
neko259
User notifications (BB-59)
r990 TEMPLATE = 'boards/notifications.html'
PARAM_PAGE = 'page'
PARAM_USERNAME = 'notification_username'
REQUEST_PAGE = 'page'
RESULTS_PER_PAGE = 10
class NotificationView(BaseBoardView):
def get(self, request, username):
params = self.get_context_data()
settings_manager = get_settings_manager(request)
# If we open our notifications, reset the "new" count
my_username = settings_manager.get_setting(SETTING_USERNAME)
neko259
Added notification API
r994
neko259
Use only lowercase name in notifications. Refactored post manager and refmap...
r1008 notification_username = username.lower()
posts = Notification.objects.get_notification_posts(
neko259
Refactored views
r1090 username=notification_username)
neko259
Use only lowercase name in notifications. Refactored post manager and refmap...
r1008 if notification_username == my_username:
neko259
Added notification API
r994 last = posts.first()
neko259
User notifications (BB-59)
r990 if last is not None:
last_id = last.id
settings_manager.set_setting(SETTING_LAST_NOTIFICATION_ID,
last_id)
paginator = get_paginator(posts, RESULTS_PER_PAGE)
neko259
Refactored views
r1090 page = int(request.GET.get(REQUEST_PAGE, DEFAULT_PAGE))
neko259
User notifications (BB-59)
r990
params[PARAM_PAGE] = paginator.page(page)
neko259
Use only lowercase name in notifications. Refactored post manager and refmap...
r1008 params[PARAM_USERNAME] = notification_username
neko259
User notifications (BB-59)
r990
return render(request, TEMPLATE, params)