2012-05-03 10:52:43 +08:00
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
2014-03-05 14:10:05 +08:00
|
|
|
|
2014-07-09 15:04:03 +08:00
|
|
|
import re
|
2015-09-21 11:48:07 +08:00
|
|
|
|
|
|
|
from constance import config
|
|
|
|
|
2014-05-07 12:09:35 +08:00
|
|
|
from seahub.settings import SEAFILE_VERSION, SITE_TITLE, SITE_NAME, \
|
2015-09-21 11:48:07 +08:00
|
|
|
MAX_FILE_NAME, BRANDING_CSS, LOGO_PATH, LOGO_WIDTH, LOGO_HEIGHT,\
|
|
|
|
SHOW_REPO_DOWNLOAD_BUTTON, SHARE_LINK_PASSWORD_MIN_LENGTH
|
2013-12-10 12:14:12 +08:00
|
|
|
|
2013-03-17 15:43:33 +08:00
|
|
|
try:
|
|
|
|
from seahub.settings import SEACLOUD_MODE
|
|
|
|
except ImportError:
|
|
|
|
SEACLOUD_MODE = False
|
2012-05-03 10:52:43 +08:00
|
|
|
|
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
|
|
|
|
2013-05-21 21:42:59 +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
|
2013-05-21 21:42:59 +08:00
|
|
|
|
2014-03-05 14:10:05 +08:00
|
|
|
try:
|
|
|
|
from seahub.settings import MULTI_TENANCY
|
|
|
|
except ImportError:
|
|
|
|
MULTI_TENANCY = False
|
2014-07-07 16:05:14 +08:00
|
|
|
|
2012-05-30 22:42:21 +08:00
|
|
|
def base(request):
|
2012-05-03 10:52:43 +08:00
|
|
|
"""
|
2012-05-30 22:42:21 +08:00
|
|
|
Add seahub base configure to the context.
|
2012-05-03 10:52:43 +08:00
|
|
|
|
|
|
|
"""
|
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:
|
2012-09-01 17:46:46 +08:00
|
|
|
base_template = 'myhome_base.html'
|
2012-10-26 19:15:52 +08:00
|
|
|
|
2014-03-03 13:39:25 +08:00
|
|
|
# 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
|
|
|
|
2014-07-09 15:04:03 +08:00
|
|
|
# extra repo id from request path, use in search
|
|
|
|
repo_id_patt = r".*/([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})/.*"
|
|
|
|
m = re.match(repo_id_patt, request.get_full_path())
|
|
|
|
search_repo_id = m.group(1) if m is not None else None
|
|
|
|
|
2012-05-30 22:42:21 +08:00
|
|
|
return {
|
2012-08-01 17:42:28 +08:00
|
|
|
'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,
|
2014-01-03 14:12:50 +08:00
|
|
|
'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,
|
2015-09-21 11:48:07 +08:00
|
|
|
'enable_signup': config.ENABLE_SIGNUP,
|
2012-12-25 15:05:12 +08:00
|
|
|
'max_file_name': MAX_FILE_NAME,
|
2013-05-29 12:13:02 +08:00
|
|
|
'has_file_search': HAS_FILE_SEARCH,
|
2013-05-21 21:42:59 +08:00
|
|
|
'enable_pubfile': ENABLE_PUBFILE,
|
2013-11-05 17:03:00 +08:00
|
|
|
'show_repo_download_button': SHOW_REPO_DOWNLOAD_BUTTON,
|
2015-08-12 15:20:12 +08:00
|
|
|
'share_link_password_min_length': SHARE_LINK_PASSWORD_MIN_LENGTH,
|
2015-09-21 11:48:07 +08:00
|
|
|
'repo_password_min_length': config.REPO_PASSWORD_MIN_LENGTH,
|
2013-12-10 12:14:12 +08:00
|
|
|
'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,
|
2014-03-05 14:10:05 +08:00
|
|
|
'multi_tenancy': MULTI_TENANCY,
|
2014-07-09 15:04:03 +08:00
|
|
|
'search_repo_id': search_repo_id,
|
2012-05-30 22:42:21 +08:00
|
|
|
}
|