##// END OF EJS Templates
Delete thread when banning OP
Delete thread when banning OP

File last commit:

r1760:641fa167 default
r1901:fd30e4ee default
Show More
context_processors.py
85 lines | 3.2 KiB | text/x-python | PythonLexer
/ boards / context_processors.py
neko259
User notifications (BB-59)
r990 from boards.abstracts.settingsmanager import get_settings_manager, \
neko259
Switch to show only favorite tags (BB-94)
r1691 SETTING_LAST_NOTIFICATION_ID, SETTING_IMAGE_VIEWER, SETTING_ONLY_FAVORITES
neko259
Remove websocket support. JS internal auto-update works fine enough
r1760 from boards.models import Banner
neko259
User notifications (BB-59)
r990 from boards.models.user import Notification
neko259
Subscribe to a multiple of users for notifications
r1429 from boards import settings
neko259
Speed up getting new post count for favorites. Get favorites at page start, not only by JS
r1455 from boards.models import Post, Tag, Thread
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690
neko259
Small code cleanups
r721 CONTEXT_SITE_NAME = 'site_name'
CONTEXT_VERSION = 'version'
CONTEXT_THEME_CSS = 'theme_css'
CONTEXT_THEME = 'theme'
CONTEXT_PPD = 'posts_per_day'
CONTEXT_USER = 'user'
neko259
User notifications (BB-59)
r990 CONTEXT_NEW_NOTIFICATIONS_COUNT = 'new_notifications_count'
neko259
Subscribe to a multiple of users for notifications
r1429 CONTEXT_USERNAMES = 'usernames'
neko259
Refactoring
r1027 CONTEXT_TAGS_STR = 'tags_str'
neko259
Setting for image view mode: in post (simple) or in popup
r1122 CONTEXT_IMAGE_VIEWER = 'image_viewer'
neko259
Added favorite thread popup
r1340 CONTEXT_HAS_FAV_THREADS = 'has_fav_threads'
neko259
Added PoW instead of 30-second captcha
r1428 CONTEXT_POW_DIFFICULTY = 'pow_difficulty'
neko259
Speed up getting new post count for favorites. Get favorites at page start, not only by JS
r1455 CONTEXT_NEW_POST_COUNT = 'new_post_count'
neko259
Load banners in all pages
r1646 CONTEXT_BANNERS = 'banners'
neko259
Switch to show only favorite tags (BB-94)
r1691 CONTEXT_ONLY_FAVORITES = 'only_favorites'
neko259
Use native django auth for moderation
r811
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690
neko259
Refactored default context processor
r1680 def get_notifications(context, settings_manager):
neko259
Subscribe to a multiple of users for notifications
r1429 usernames = settings_manager.get_notification_usernames()
neko259
User notifications (BB-59)
r990 new_notifications_count = 0
neko259
Refactored default context processor
r1680 if usernames:
neko259
User notifications (BB-59)
r990 last_notification_id = settings_manager.get_setting(
SETTING_LAST_NOTIFICATION_ID)
neko259
Added notification API
r994
new_notifications_count = Notification.objects.get_notification_posts(
neko259
Speed up getting new post count for favorites. Get favorites at page start, not only by JS
r1455 usernames=usernames, last=last_notification_id).only('id').count()
neko259
User notifications (BB-59)
r990 context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count
neko259
Subscribe to a multiple of users for notifications
r1429 context[CONTEXT_USERNAMES] = usernames
neko259
User notifications (BB-59)
r990
neko259
Refactored default context processor
r1680 def get_new_post_count(context, settings_manager):
neko259
Speed up getting new post count for favorites. Get favorites at page start, not only by JS
r1455 fav_threads = settings_manager.get_fav_threads()
neko259
Refactored default context processor
r1680 if fav_threads:
fav_thread_ops = Post.objects.filter(id__in=fav_threads.keys()) \
.order_by('-pub_time').only('thread_id', 'pub_time')
ops = [{'op': op, 'last_id': fav_threads[str(op.id)]} for op in fav_thread_ops]
count = Thread.objects.get_new_post_count(ops)
if count > 0:
context[CONTEXT_NEW_POST_COUNT] = '(+{})'.format(count)
neko259
Speed up getting new post count for favorites. Get favorites at page start, not only by JS
r1455
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690 def user_and_ui_processor(request):
neko259
Cleaned up some code
r905 context = dict()
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690
neko259
Small code cleanups
r721 context[CONTEXT_PPD] = float(Post.objects.get_posts_per_day())
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690
neko259
Divided settings manager into base settings manager class and session-based settings manager. This allowes to add other backends to the settings manager
r730 settings_manager = get_settings_manager(request)
neko259
Refactoring
r1027 fav_tags = settings_manager.get_fav_tags()
neko259
Favorite threads with new posts counter
r1323
neko259
Refactoring
r1027 context[CONTEXT_TAGS_STR] = Tag.objects.get_tag_url_list(fav_tags)
neko259
Removed user and settings mode. Added settings manager to manage settings and keep them in the session (or any other backend like cookie in the future
r728 theme = settings_manager.get_theme()
neko259
Small code cleanups
r721 context[CONTEXT_THEME] = theme
neko259
Refactored default context processor
r1680
# TODO Use static here
neko259
Small code cleanups
r721 context[CONTEXT_THEME_CSS] = 'css/' + theme + '/base_page.css'
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690
neko259
Implemented ini settings parser
r1153 context[CONTEXT_VERSION] = settings.get('Version', 'Version')
context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName')
neko259
Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules
r690
neko259
Separate settings to limit first posting from the session or every post
r1607 if (settings.get_bool('Forms', 'LimitFirstPosting') and not settings_manager.get_setting('confirmed_user'))\
or settings.get_bool('Forms', 'LimitPostingSpeed'):
neko259
Added PoW instead of 30-second captcha
r1428 context[CONTEXT_POW_DIFFICULTY] = settings.get_int('Forms', 'PowDifficulty')
neko259
Setting for image view mode: in post (simple) or in popup
r1122 context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting(
neko259
Implemented ini settings parser
r1153 SETTING_IMAGE_VIEWER,
default=settings.get('View', 'DefaultImageViewer'))
neko259
Setting for image view mode: in post (simple) or in popup
r1122
neko259
Added favorite thread popup
r1340 context[CONTEXT_HAS_FAV_THREADS] =\
len(settings_manager.get_fav_threads()) > 0
neko259
Load banners in all pages
r1646 context[CONTEXT_BANNERS] = Banner.objects.order_by('-id')
neko259
Switch to show only favorite tags (BB-94)
r1691 context[CONTEXT_ONLY_FAVORITES] = settings_manager.get_setting(
SETTING_ONLY_FAVORITES, False)
neko259
Show search button only if haystack is enabled
r1478
neko259
Refactored default context processor
r1680 get_notifications(context, settings_manager)
get_new_post_count(context, settings_manager)
neko259
User notifications (BB-59)
r990
neko259
Use native django auth for moderation
r811 return context