##// END OF EJS Templates
Fixed license text
Fixed license text

File last commit:

r730:447bb8d7 2.0-dev
r739:809d6f1e default
Show More
context_processors.py
38 lines | 1.1 KiB | text/x-python | PythonLexer
/ boards / context_processors.py
neko259
Small code cleanups
r721 __author__ = 'neko259'
neko259
Moved imageboard settings to the boards settings module. Added setting to disable archive
r716 from boards import utils, 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
from boards.models.post import SETTING_MODERATE
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
def user_and_ui_processor(request):
context = {}
user = utils.get_user(request)
neko259
Small code cleanups
r721 context[CONTEXT_USER] = user
context[CONTEXT_TAGS] = user.fav_tags.all()
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
theme = utils.get_theme(request, user)
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
moderate = user.get_setting(SETTING_MODERATE)
if moderate == 'True':
neko259
Small code cleanups
r721 context[CONTEXT_MODERATOR] = user.is_moderator()
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 else:
neko259
Small code cleanups
r721 context[CONTEXT_MODERATOR] = False
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
return context