##// END OF EJS Templates
Close form by default, open it under the post that is replied
Close form by default, open it under the post that is replied

File last commit:

r1008:bbb4d5fd default
r1056:0da38729 default
Show More
notifications.py
44 lines | 1.5 KiB | text/x-python | PythonLexer
from django.shortcuts import render
from boards.abstracts.paginator import get_paginator
from boards.abstracts.settingsmanager import get_settings_manager, \
SETTING_USERNAME, SETTING_LAST_NOTIFICATION_ID
from boards.models import Post
from boards.models.user import Notification
from boards.views.base import BaseBoardView
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)
notification_username = username.lower()
posts = Notification.objects.get_notification_posts(
username=notification_username)
if notification_username == my_username:
last = posts.first()
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)
page = int(request.GET.get(REQUEST_PAGE, '1'))
params[PARAM_PAGE] = paginator.page(page)
params[PARAM_USERNAME] = notification_username
return render(request, TEMPLATE, params)