1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 02:42:47 +00:00
Files
seahub/seahub/base/context_processors.py

74 lines
2.2 KiB
Python
Raw Normal View History

"""
A set of request processors that return dictionaries to be merged into a
template context. Each function takes the request object as its only parameter
and returns a dictionary to add to the context.
These are referenced from the setting TEMPLATE_CONTEXT_PROCESSORS and used by
RequestContext.
"""
from seahub.settings import SEAFILE_VERSION, SITE_TITLE, SITE_NAME, SITE_BASE, \
ENABLE_SIGNUP, MAX_FILE_NAME, BRANDING_CSS, LOGO_PATH, LOGO_WIDTH, LOGO_HEIGHT,\
SHOW_REPO_DOWNLOAD_BUTTON, REPO_PASSWORD_MIN_LENGTH
2013-03-17 15:43:33 +08:00
try:
from seahub.settings import SEACLOUD_MODE
except ImportError:
SEACLOUD_MODE = False
2014-02-26 18:24:34 +08:00
from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, TRAFFIC_STATS_ENABLED
2013-03-09 14:15:53 +08:00
try:
from seahub.settings import ENABLE_PUBFILE
except ImportError:
ENABLE_PUBFILE = False
2014-03-17 14:49:00 +08:00
try:
from seahub.settings import ENABLE_SYSADMIN_EXTRA
except ImportError:
ENABLE_SYSADMIN_EXTRA = False
def base(request):
"""
Add seahub base configure to the context.
"""
2012-08-31 17:28:50 +08:00
try:
org = request.user.org
except AttributeError:
org = None
try:
base_template = request.base_template
except AttributeError:
base_template = 'myhome_base.html'
2012-10-26 19:15:52 +08:00
username = request.user.username
# get 8 user groups
2014-03-04 11:37:03 +08:00
try:
grps = request.user.joined_groups[:8]
except AttributeError: # anonymous user
grps = None
2014-02-08 14:44:44 +08:00
return {
'seafile_version': SEAFILE_VERSION,
2012-11-07 20:39:59 +08:00
'site_title': SITE_TITLE,
2013-04-19 11:50:57 +02:00
'branding_css': BRANDING_CSS,
'logo_path': LOGO_PATH,
'logo_width': LOGO_WIDTH,
'logo_height': LOGO_HEIGHT,
2013-03-17 15:43:33 +08:00
'seacloud_mode': SEACLOUD_MODE,
2012-08-01 22:34:35 +08:00
'cloud_mode': request.cloud_mode,
2012-08-31 17:28:50 +08:00
'org': org,
'base_template': base_template,
2012-10-30 19:37:47 +08:00
'site_name': SITE_NAME,
2012-12-19 14:11:32 +08:00
'enable_signup': ENABLE_SIGNUP,
2012-12-25 15:05:12 +08:00
'max_file_name': MAX_FILE_NAME,
'has_file_search': HAS_FILE_SEARCH,
'enable_pubfile': ENABLE_PUBFILE,
'show_repo_download_button': SHOW_REPO_DOWNLOAD_BUTTON,
'repo_password_min_length': REPO_PASSWORD_MIN_LENGTH,
'events_enabled': EVENTS_ENABLED,
2014-02-26 18:24:34 +08:00
'traffic_stats_enabled': TRAFFIC_STATS_ENABLED,
2014-03-17 14:49:00 +08:00
'sysadmin_extra_enabled': ENABLE_SYSADMIN_EXTRA,
2014-02-08 14:44:44 +08:00
'grps': grps,
}