##// END OF EJS Templates
Merged with default branch
Merged with default branch

File last commit:

r905:90224a9f default
r933:ce97c754 merge decentral
Show More
context_processors.py
41 lines | 1.1 KiB | text/x-python | PythonLexer
/ boards / context_processors.py
neko259
Cleaned up some code
r905 from boards.abstracts.settingsmanager import get_settings_manager
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
neko259
Small code cleanups
r721 __author__ = 'neko259'
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 from boards import settings
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 from boards.models import Post
neko259
Small code cleanups
r721 CONTEXT_SITE_NAME = 'site_name'
CONTEXT_VERSION = 'version'
CONTEXT_MODERATOR = 'moderator'
CONTEXT_THEME_CSS = 'theme_css'
CONTEXT_THEME = 'theme'
CONTEXT_PPD = 'posts_per_day'
CONTEXT_TAGS = 'tags'
CONTEXT_USER = 'user'
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
Use native django auth for moderation
r811 PERMISSION_MODERATE = 'moderation'
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
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 context[CONTEXT_TAGS] = settings_manager.get_fav_tags()
theme = settings_manager.get_theme()
neko259
Small code cleanups
r721 context[CONTEXT_THEME] = theme
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
# This shows the moderator panel
neko259
Updated context processor to work with a request without user defined (fixes...
r813 try:
neko259
Cleaned up some code
r905 moderate = request.user.has_perm(PERMISSION_MODERATE)
neko259
Updated context processor to work with a request without user defined (fixes...
r813 except AttributeError:
moderate = False
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 context[CONTEXT_MODERATOR] = moderate
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_VERSION] = settings.VERSION
context[CONTEXT_SITE_NAME] = settings.SITE_NAME
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
Use native django auth for moderation
r811 return context