1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-07 09:51:26 +00:00
Files
seahub/seahub/settings.py

639 lines
20 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2011-03-19 13:15:02 +08:00
# Django settings for seahub project.
2012-06-07 11:48:25 +08:00
import sys
2011-03-19 13:15:02 +08:00
import os
2012-06-07 11:48:25 +08:00
import re
import random
import string
from seaserv import FILE_SERVER_ROOT, FILE_SERVER_PORT, SERVICE_URL
2013-07-25 13:30:19 +08:00
2013-06-04 17:39:25 +08:00
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)
2011-03-19 13:15:02 +08:00
DEBUG = False
2011-03-19 13:15:02 +08:00
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
2013-06-04 17:39:25 +08:00
'NAME': '%s/seahub/seahub.db' % PROJECT_ROOT, # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
2011-03-19 13:15:02 +08:00
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
2012-01-30 18:14:05 +08:00
TIME_ZONE = 'Asia/Shanghai'
2011-03-19 13:15:02 +08:00
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
2012-10-26 19:15:52 +08:00
LANGUAGE_CODE = 'en'
2011-03-19 13:15:02 +08:00
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = False
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
2013-06-04 17:39:25 +08:00
MEDIA_ROOT = '%s/media/' % PROJECT_ROOT
2011-03-19 13:15:02 +08:00
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = '%s/assets/' % MEDIA_ROOT
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/media/assets/'
2011-03-19 13:15:02 +08:00
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'%s/static' % PROJECT_ROOT,
)
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
2015-04-14 17:17:05 +08:00
# StaticI18N config
STATICI18N_ROOT = '%s/static/scripts' % PROJECT_ROOT
STATICI18N_OUTPUT_DIR = 'i18n'
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
2015-04-09 17:05:01 +08:00
'compressor.finders.CompressorFinder',
)
2011-03-19 13:15:02 +08:00
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'n*v0=jz-1rz@(4gx^tf%6^e7c&um@2)g-l=3_)t@19a69n1nv6'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
2011-03-19 13:15:02 +08:00
)
2013-06-04 17:39:25 +08:00
# Order is important
2011-03-19 13:15:02 +08:00
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
2013-05-04 17:38:38 +08:00
'django.middleware.locale.LocaleMiddleware',
2013-06-04 17:39:25 +08:00
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
2013-05-07 10:33:26 +08:00
'seahub.auth.middleware.AuthenticationMiddleware',
'seahub.base.middleware.BaseMiddleware',
'seahub.base.middleware.InfobarMiddleware',
2015-07-22 15:03:33 +08:00
'seahub.password_session.middleware.CheckPasswordHash'
2011-03-19 13:15:02 +08:00
)
SITE_ROOT_URLCONF = 'seahub.urls'
ROOT_URLCONF = 'djblets.util.rooturl'
SITE_ROOT = '/'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'seahub.wsgi.application'
2011-03-19 13:15:02 +08:00
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
2013-12-23 15:53:31 +08:00
os.path.join(PROJECT_ROOT, '../../seahub-data/custom/templates'),
2013-06-04 17:39:25 +08:00
os.path.join(PROJECT_ROOT, 'seahub/templates'),
2011-03-19 13:15:02 +08:00
)
2012-10-26 19:15:52 +08:00
# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
gettext_noop = lambda s: s
LANGUAGES = (
2014-02-20 14:20:43 +08:00
('ca', gettext_noop('català')),
('de', gettext_noop(u'Deutsch')),
2013-06-28 16:07:53 +08:00
('en', gettext_noop('English')),
('es', gettext_noop('Español')),
2015-07-30 11:08:08 +08:00
('es-ar', gettext_noop('Español de Argentina')),
('es-mx', gettext_noop('Español de México')),
2014-02-20 14:20:43 +08:00
('fr', gettext_noop('français')),
('he', gettext_noop('עברית')),
2013-04-08 19:53:30 +02:00
('hu', gettext_noop('Magyar')),
2014-02-20 14:20:43 +08:00
('is', gettext_noop('Íslenska')),
2013-12-26 11:08:05 +08:00
('it', gettext_noop('Italiano')),
('ja', gettext_noop('日本語')),
2014-02-20 14:20:43 +08:00
('ko', gettext_noop('한국어')),
2013-12-26 11:08:05 +08:00
('lv', gettext_noop('Latvian')),
2014-02-20 14:20:43 +08:00
('nl', gettext_noop('Nederlands')),
('pl', gettext_noop('Polski')),
2013-10-30 16:15:44 +08:00
('pt-br', gettext_noop('Portuguese, Brazil')),
2013-12-26 11:08:05 +08:00
('ru', gettext_noop(u'Русский')),
('sk', gettext_noop('Slovak')),
2014-07-30 10:56:57 +08:00
('sl', gettext_noop('Slovenian')),
2014-02-20 14:20:43 +08:00
('sv', gettext_noop('Svenska')),
2015-02-04 11:34:57 +08:00
('th', gettext_noop('ไทย')),
('tr', gettext_noop('Türkçe')),
2014-02-20 14:20:43 +08:00
('uk', gettext_noop('українська мова')),
2013-06-28 16:07:53 +08:00
('zh-cn', gettext_noop(u'简体中文')),
2013-08-05 11:42:59 +08:00
('zh-tw', gettext_noop(u'繁體中文')),
2012-10-26 19:15:52 +08:00
)
LOCALE_PATHS = (
2013-06-04 17:39:25 +08:00
os.path.join(PROJECT_ROOT, 'locale'),
2012-10-26 19:15:52 +08:00
)
2011-03-19 22:40:55 +08:00
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
2011-03-19 22:40:55 +08:00
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
2011-03-19 22:40:55 +08:00
'django.core.context_processors.media',
2015-04-14 17:17:05 +08:00
'django.core.context_processors.static',
2011-03-19 22:40:55 +08:00
'djblets.util.context_processors.siteRoot',
'django.core.context_processors.request',
2012-06-12 10:13:14 +08:00
'django.contrib.messages.context_processors.messages',
'seahub.base.context_processors.base',
2011-03-19 22:40:55 +08:00
)
2011-03-19 13:15:02 +08:00
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
2012-06-12 10:13:14 +08:00
'django.contrib.messages',
'django.contrib.staticfiles',
2012-06-07 11:48:25 +08:00
'registration',
'captcha',
2015-04-09 17:05:01 +08:00
'compressor',
2015-04-14 17:17:05 +08:00
'statici18n',
'constance',
'constance.backends.database',
2012-08-07 19:50:10 +08:00
'seahub.api2',
'seahub.avatar',
'seahub.base',
2012-05-04 16:30:07 +08:00
'seahub.contacts',
2013-04-06 19:09:33 +08:00
'seahub.wiki',
2012-06-07 11:48:25 +08:00
'seahub.group',
2013-05-27 13:35:57 +08:00
'seahub.message',
2012-07-26 17:08:31 +08:00
'seahub.notifications',
'seahub.options',
2012-07-26 17:08:31 +08:00
'seahub.profile',
2012-06-12 10:13:14 +08:00
'seahub.share',
2013-12-17 17:49:11 +08:00
'seahub.help',
'seahub.thumbnail',
2015-07-22 15:03:33 +08:00
'seahub.password_session',
2011-03-19 13:15:02 +08:00
)
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'
CONSTANCE_DATABASE_CACHE_BACKEND = 'default'
2013-05-17 11:12:32 +08:00
AUTHENTICATION_BACKENDS = (
2013-05-07 10:33:26 +08:00
'seahub.base.accounts.AuthBackend',
)
2015-05-29 11:51:57 +08:00
LOGIN_REDIRECT_URL = '/profile/'
2016-01-05 12:07:58 +08:00
LOGIN_URL = SITE_ROOT + 'accounts/login'
2015-05-29 11:51:57 +08:00
ACCOUNT_ACTIVATION_DAYS = 7
2015-10-20 16:35:54 +08:00
# allow seafile amdin view user's repo
ENABLE_SYS_ADMIN_VIEW_REPO = False
2015-09-11 11:00:54 +08:00
# show traffic on the UI
SHOW_TRAFFIC = True
# Enable or disable make group public
ENABLE_MAKE_GROUP_PUBLIC = False
2013-12-06 14:02:11 +08:00
# show or hide library 'download' button
SHOW_REPO_DOWNLOAD_BUTTON = False
# enable 'upload folder' or not
ENABLE_UPLOAD_FOLDER = False
# enable resumable fileupload or not
ENABLE_RESUMABLE_FILEUPLOAD = False
2015-09-24 17:20:45 +08:00
# enable encrypt library
ENABLE_ENCRYPTED_LIBRARY = True
2015-09-24 17:20:45 +08:00
# mininum length for password of encrypted library
2014-06-26 14:48:44 +03:00
REPO_PASSWORD_MIN_LENGTH = 8
2015-08-12 15:20:12 +08:00
# mininum length for the password of a share link
SHARE_LINK_PASSWORD_MIN_LENGTH = 8
# mininum length for user's password
USER_PASSWORD_MIN_LENGTH = 6
# LEVEL based on four types of input:
# num, upper letter, lower letter, other symbols
# '3' means password must have at least 3 types of the above.
USER_PASSWORD_STRENGTH_LEVEL = 3
# default False, only check USER_PASSWORD_MIN_LENGTH
# when True, check password strength level, STRONG(or above) is allowed
USER_STRONG_PASSWORD_REQUIRED = False
2013-12-06 14:36:06 +08:00
# Using server side crypto by default, otherwise, let user choose crypto method.
FORCE_SERVER_CRYPTO = True
2014-02-13 16:57:18 +08:00
# Enable or disable repo history setting
ENABLE_REPO_HISTORY_SETTING = True
# Enable or disable org repo creation by user
ENABLE_USER_CREATE_ORG_REPO = True
DISABLE_SYNC_WITH_ANY_FOLDER = False
2012-07-04 20:32:54 +08:00
# File preview
2013-03-25 16:22:10 +08:00
FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
OFFICE_PREVIEW_MAX_SIZE = 2 * 1024 * 1024
2013-01-09 15:32:44 +08:00
USE_PDFJS = True
FILE_ENCODING_LIST = ['auto', 'utf-8', 'gbk', 'ISO-8859-1', 'ISO-8859-5']
FILE_ENCODING_TRY_LIST = ['utf-8', 'gbk']
HIGHLIGHT_KEYWORD = False # If True, highlight the keywords in the file when the visit is via clicking a link in 'search result' page.
2012-07-02 22:45:21 +08:00
2014-01-02 11:24:25 +08:00
# Common settings(file extension, storage) for avatar and group avatar.
AVATAR_FILE_STORAGE = '' # Replace with 'seahub.base.database_storage.DatabaseStorage' if save avatar files to database
AVATAR_ALLOWED_FILE_EXTS = ('.jpg', '.png', '.jpeg', '.gif')
2012-07-04 20:32:54 +08:00
# Avatar
2012-05-24 20:19:14 +08:00
AVATAR_STORAGE_DIR = 'avatars'
2014-01-22 12:20:54 +08:00
AVATAR_HASH_USERDIRNAMES = True
2014-05-14 15:33:09 +08:00
AVATAR_HASH_FILENAMES = True
2012-05-24 20:19:14 +08:00
AVATAR_GRAVATAR_BACKUP = False
2014-01-17 13:34:55 +08:00
AVATAR_DEFAULT_URL = '/avatars/default.png'
2012-10-22 17:50:09 +08:00
AVATAR_DEFAULT_NON_REGISTERED_URL = '/avatars/default-non-register.jpg'
2012-05-25 14:14:51 +08:00
AVATAR_MAX_AVATARS_PER_USER = 1
2013-08-09 13:48:42 +08:00
AVATAR_CACHE_TIMEOUT = 14 * 24 * 60 * 60
AUTO_GENERATE_AVATAR_SIZES = (16, 20, 24, 28, 32, 36, 40, 48, 60, 80, 290)
# Group avatar
GROUP_AVATAR_STORAGE_DIR = 'avatars/groups'
GROUP_AVATAR_DEFAULT_URL = 'avatars/groups/default.png'
2014-02-10 16:56:19 +08:00
AUTO_GENERATE_GROUP_AVATAR_SIZES = (20, 24, 32, 36, 48, 56)
2011-04-30 13:31:10 +08:00
2013-08-05 11:38:26 +08:00
LOG_DIR = os.environ.get('SEAHUB_LOG_DIR', '/tmp')
2013-03-22 00:58:00 +08:00
CACHE_DIR = "/tmp"
install_topdir = os.path.expanduser(os.path.join(os.path.dirname(__file__), '..', '..', '..'))
central_conf_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR', '')
2013-03-22 00:58:00 +08:00
if 'win32' in sys.platform:
try:
CCNET_CONF_PATH = os.environ['CCNET_CONF_DIR']
if not CCNET_CONF_PATH: # If it's set but is an empty string.
raise KeyError
except KeyError:
raise ImportError("Settings cannot be imported, because environment variable CCNET_CONF_DIR is undefined.")
else:
2013-09-02 13:24:34 +08:00
LOG_DIR = os.environ.get('SEAHUB_LOG_DIR', os.path.join(CCNET_CONF_PATH, '..'))
2013-03-22 00:58:00 +08:00
CACHE_DIR = os.path.join(CCNET_CONF_PATH, '..')
install_topdir = os.path.join(CCNET_CONF_PATH, '..')
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
2013-03-22 00:58:00 +08:00
'LOCATION': os.path.join(CACHE_DIR, 'seahub_cache'),
'OPTIONS': {
'MAX_ENTRIES': 1000000
}
}
}
2012-12-28 17:14:51 +08:00
# rest_framwork
2012-12-26 11:03:38 +08:00
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_RATES': {
2014-12-29 18:10:06 +08:00
'ping': '600/minute',
2012-12-26 11:03:38 +08:00
'anon': '5/minute',
'user': '300/minute',
},
}
2012-12-28 17:14:51 +08:00
# file and path
2012-12-25 15:05:12 +08:00
MAX_UPLOAD_FILE_NAME_LEN = 255
MAX_FILE_NAME = MAX_UPLOAD_FILE_NAME_LEN
MAX_PATH = 4096
2012-07-04 20:32:54 +08:00
2015-07-11 10:10:31 +08:00
FILE_LOCK_EXPIRATION_DAYS = 0
# Whether or not activate user when registration complete.
# If set to ``False``, new user will be activated by admin or via activate link.
2012-07-04 20:32:54 +08:00
ACTIVATE_AFTER_REGISTRATION = True
# Whether or not send activation Email to user when registration complete.
# This option will be ignored if ``ACTIVATE_AFTER_REGISTRATION`` set to ``True``.
2012-07-04 20:32:54 +08:00
REGISTRATION_SEND_MAIL = False
2013-12-18 13:56:20 +08:00
REQUIRE_DETAIL_ON_REGISTRATION = False
2012-08-06 16:30:51 +08:00
# Account initial password, for password resetting.
# INIT_PASSWD can either be a string, or a function (function has to be set without the brackets)
def genpassword():
return ''.join([random.choice(string.digits + string.letters) for i in range(0, 10)])
INIT_PASSWD = genpassword
2012-08-06 16:30:51 +08:00
2012-11-07 20:39:59 +08:00
# browser tab title
SITE_TITLE = 'Private Seafile'
2012-07-04 20:32:54 +08:00
2015-10-10 11:03:50 +08:00
# Base name used in email sending
2012-11-07 20:39:59 +08:00
SITE_NAME = 'Seafile'
2012-07-04 20:32:54 +08:00
# Path to the Logo Imagefile (relative to the media path)
2013-12-12 15:03:10 +08:00
LOGO_PATH = 'img/seafile_logo.png'
# logo size. the unit is 'px'
2014-01-17 13:34:55 +08:00
LOGO_WIDTH = 149
LOGO_HEIGHT = 32
2013-09-17 11:36:45 +08:00
# css to modify the seafile css (e.g. css/my_site.css)
BRANDING_CSS = ''
# Using Django to server static file. Set to `False` if deployed behide a web
# server.
SERVE_STATIC = True
2015-09-21 11:48:07 +08:00
# Enable or disable registration on web.
2012-12-19 14:11:32 +08:00
ENABLE_SIGNUP = False
2012-06-07 11:48:25 +08:00
2013-05-20 10:33:39 +08:00
# For security consideration, please set to match the host/domain of your site, e.g., ALLOWED_HOSTS = ['.example.com'].
# Please refer https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts for details.
ALLOWED_HOSTS = ['*']
2012-12-27 20:48:38 +08:00
# Logging
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
2013-01-09 17:28:56 +08:00
'format': '%(asctime)s [%(levelname)s] %(name)s:%(lineno)s %(funcName)s %(message)s'
2012-12-27 20:48:38 +08:00
},
},
2013-06-01 16:03:58 +08:00
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
2012-12-27 20:48:38 +08:00
'handlers': {
'default': {
'level':'WARN',
'class':'logging.handlers.RotatingFileHandler',
2013-03-22 00:58:00 +08:00
'filename': os.path.join(LOG_DIR, 'seahub.log'),
2012-12-27 20:48:38 +08:00
'maxBytes': 1024*1024*10, # 10 MB
'formatter':'standard',
},
2012-12-27 20:48:38 +08:00
'request_handler': {
'level':'WARN',
'class':'logging.handlers.RotatingFileHandler',
2013-03-22 00:58:00 +08:00
'filename': os.path.join(LOG_DIR, 'seahub_django_request.log'),
2012-12-27 20:48:38 +08:00
'maxBytes': 1024*1024*10, # 10 MB
'formatter':'standard',
},
'mail_admins': {
'level': 'ERROR',
2013-06-01 16:03:58 +08:00
'filters': ['require_debug_false'],
2012-12-27 20:48:38 +08:00
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'': {
'handlers': ['default'],
'level': 'WARN',
'propagate': True
},
'django.request': {
'handlers': ['request_handler', 'mail_admins'],
'level': 'WARN',
'propagate': False
},
}
}
#Login Attempt
2014-08-05 14:47:39 +08:00
LOGIN_ATTEMPT_LIMIT = 3
LOGIN_ATTEMPT_TIMEOUT = 15 * 60 # in seconds (default: 15 minutes)
2014-01-02 16:20:39 +08:00
# Age of cookie, in seconds (default: 1 day).
SESSION_COOKIE_AGE = 24 * 60 * 60
# Days of remembered login info (deafult: 7 days)
LOGIN_REMEMBER_DAYS = 7
2014-01-02 16:20:39 +08:00
2015-11-03 11:14:59 +08:00
SEAFILE_VERSION = '5.0.0'
2014-01-22 14:01:02 +08:00
2015-04-09 17:05:01 +08:00
# Compress static files(css, js)
COMPRESS_URL = MEDIA_URL
COMPRESS_ROOT = MEDIA_ROOT
COMPRESS_DEBUG_TOGGLE = 'nocompress'
COMPRESS_CSS_HASHING_METHOD = 'content'
2015-04-10 14:15:38 +08:00
COMPRESS_CSS_FILTERS = [
'compressor.filters.css_default.CssAbsoluteFilter',
'compressor.filters.cssmin.CSSMinFilter',
]
2015-04-10 11:01:39 +08:00
2015-04-09 17:05:01 +08:00
2014-12-23 17:34:36 +08:00
###################
# Image Thumbnail #
###################
# Enable or disable thumbnail
2014-12-27 19:07:09 +08:00
ENABLE_THUMBNAIL = True
2014-12-23 17:34:36 +08:00
# Absolute filesystem path to the directory that will hold thumbnail files.
SEAHUB_DATA_ROOT = os.path.join(PROJECT_ROOT, '../../seahub-data')
if os.path.exists(SEAHUB_DATA_ROOT):
THUMBNAIL_ROOT = os.path.join(SEAHUB_DATA_ROOT, 'thumbnail')
else:
THUMBNAIL_ROOT = os.path.join(PROJECT_ROOT, 'seahub/thumbnail/thumb')
2014-12-23 17:34:36 +08:00
THUMBNAIL_EXTENSION = 'png'
# for thumbnail: height(px) and width(px)
2015-07-25 16:30:11 +08:00
THUMBNAIL_DEFAULT_SIZE = 48
2015-10-29 17:17:40 +08:00
THUMBNAIL_SIZE_FOR_GRID = 192
2014-12-23 17:34:36 +08:00
2015-07-15 17:57:09 +08:00
# size(MB) limit for generate thumbnail
2015-11-19 12:21:54 +08:00
THUMBNAIL_IMAGE_SIZE_LIMIT = 20
2015-07-15 17:57:09 +08:00
THUMBNAIL_IMAGE_ORIGINAL_SIZE_LIMIT = 256
2015-06-10 18:42:10 +08:00
#####################
# Global AddressBook #
2015-06-10 18:42:10 +08:00
#####################
ENABLE_GLOBAL_ADDRESSBOOK = True
2015-06-10 18:42:10 +08:00
#####################
# Folder Permission #
#####################
ENABLE_FOLDER_PERM = False
#####################
# Sudo Mode #
#####################
ENABLE_SUDO_MODE = True
2013-01-09 17:28:56 +08:00
#################
# Email sending #
#################
2013-01-10 17:28:56 +08:00
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True # Whether to send email when a system staff adding new member.
2013-01-09 17:28:56 +08:00
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True # Whether to send email when a system staff resetting user's password.
2013-11-09 16:58:57 +08:00
##########################
# Settings for seafevents #
##########################
def get_events_conf_file():
if not 'CCNET_CONF_DIR' in os.environ:
return
ccnet_dir = os.environ['CCNET_CONF_DIR']
seafile_ini = os.path.join(ccnet_dir, 'seafile.ini')
if not os.path.exists(seafile_ini):
return
with open(seafile_ini, 'r') as fp:
seafile_data_dir = fp.read().strip()
2013-12-21 19:42:31 +08:00
seafevents_conf = os.path.join(seafile_data_dir, 'seafevents.conf')
if os.path.exists(seafevents_conf):
globals()['EVENTS_CONFIG_FILE'] = seafevents_conf
2013-11-09 16:58:57 +08:00
get_events_conf_file()
2013-05-17 11:12:32 +08:00
##########################
# Settings for Extra App #
##########################
ENABLE_PUBFILE = False
2013-08-07 13:15:05 +08:00
ENABLE_SUB_LIBRARY = True
2013-06-20 10:34:03 +08:00
############################
# Settings for Seahub Priv #
############################
# Replace from email to current user instead of email sender.
REPLACE_FROM_EMAIL = False
# Add ``Reply-to`` header, see RFC #822.
ADD_REPLY_TO_HEADER = False
CLOUD_DEMO_USER = 'demo@seafile.com'
2013-01-09 17:28:56 +08:00
#####################
# External settings #
#####################
2012-06-07 11:48:25 +08:00
def load_local_settings(module):
'''Import any symbols that begin with A-Z. Append to lists any symbols
that begin with "EXTRA_".
'''
2014-07-01 11:48:35 +08:00
if hasattr(module, 'HTTP_SERVER_ROOT'):
if not hasattr(module, 'FILE_SERVER_ROOT'):
module.FILE_SERVER_ROOT = module.HTTP_SERVER_ROOT
del module.HTTP_SERVER_ROOT
2012-06-07 11:48:25 +08:00
for attr in dir(module):
2012-07-04 20:32:54 +08:00
match = re.search('^EXTRA_(\w+)', attr)
if match:
name = match.group(1)
2012-06-07 11:48:25 +08:00
value = getattr(module, attr)
2012-07-04 20:32:54 +08:00
try:
globals()[name] += value
except KeyError:
globals()[name] = value
elif re.search('^[A-Z]', attr):
2012-06-07 11:48:25 +08:00
globals()[attr] = getattr(module, attr)
2012-07-04 20:32:54 +08:00
2013-05-30 11:31:02 +08:00
# Load seahub_extra_settings.py
2012-06-07 11:48:25 +08:00
try:
2013-05-30 11:31:02 +08:00
from seahub_extra import seahub_extra_settings
2012-06-07 11:48:25 +08:00
except ImportError:
pass
else:
2013-05-30 11:31:02 +08:00
load_local_settings(seahub_extra_settings)
del seahub_extra_settings
2012-11-07 20:39:59 +08:00
2013-05-30 11:31:02 +08:00
# Load local_settings.py
try:
import seahub.local_settings
except ImportError:
pass
else:
load_local_settings(seahub.local_settings)
del seahub.local_settings
2013-03-23 17:38:42 +08:00
2012-06-07 11:48:25 +08:00
# Load seahub_settings.py in server release
try:
if os.path.exists(central_conf_dir):
sys.path.insert(0, central_conf_dir)
2012-06-07 11:48:25 +08:00
import seahub_settings
except ImportError:
pass
else:
# In server release, sqlite3 db file is <topdir>/seahub.db
DATABASES['default']['NAME'] = os.path.join(install_topdir, 'seahub.db')
2013-03-23 17:38:42 +08:00
if 'win32' not in sys.platform:
# In server release, gunicorn is used to deploy seahub
INSTALLED_APPS += ('gunicorn', )
2012-06-07 11:48:25 +08:00
load_local_settings(seahub_settings)
del seahub_settings
# Remove install_topdir from path
2012-12-26 10:20:34 +08:00
sys.path.pop(0)
2012-12-27 20:48:38 +08:00
2013-05-30 11:31:02 +08:00
if 'win32' in sys.platform:
INSTALLED_APPS += ('django_wsgiserver', )
fp = open(os.path.join(install_topdir, "seahub.pid"), 'w')
fp.write("%d\n" % os.getpid())
fp.close()
2014-07-01 11:48:35 +08:00
INNER_FILE_SERVER_ROOT = 'http://127.0.0.1:' + FILE_SERVER_PORT
CONSTANCE_CONFIG = {
2015-09-21 11:48:07 +08:00
'SERVICE_URL': (SERVICE_URL,''),
'FILE_SERVER_ROOT': (FILE_SERVER_ROOT,''),
'DISABLE_SYNC_WITH_ANY_FOLDER': (DISABLE_SYNC_WITH_ANY_FOLDER,''),
2015-09-21 11:48:07 +08:00
'ENABLE_SIGNUP': (ENABLE_SIGNUP,''),
'ACTIVATE_AFTER_REGISTRATION': (ACTIVATE_AFTER_REGISTRATION,''),
'REGISTRATION_SEND_MAIL': (REGISTRATION_SEND_MAIL ,''),
'LOGIN_REMEMBER_DAYS': (LOGIN_REMEMBER_DAYS,''),
'ENABLE_USER_CREATE_ORG_REPO': (ENABLE_USER_CREATE_ORG_REPO, ''),
2015-09-21 11:48:07 +08:00
'ENABLE_ENCRYPTED_LIBRARY': (ENABLE_ENCRYPTED_LIBRARY,''),
2015-09-21 11:48:07 +08:00
'REPO_PASSWORD_MIN_LENGTH': (REPO_PASSWORD_MIN_LENGTH,''),
'ENABLE_REPO_HISTORY_SETTING': (ENABLE_REPO_HISTORY_SETTING,''),
'USER_STRONG_PASSWORD_REQUIRED': (USER_STRONG_PASSWORD_REQUIRED,''),
'USER_PASSWORD_MIN_LENGTH': (USER_PASSWORD_MIN_LENGTH,''),
'USER_PASSWORD_STRENGTH_LEVEL': (USER_PASSWORD_STRENGTH_LEVEL,''),
'SHARE_LINK_PASSWORD_MIN_LENGTH': (SHARE_LINK_PASSWORD_MIN_LENGTH,''),
}