mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 10:26:17 +00:00
Update settings.py
This commit is contained in:
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.8"
|
python-version: "3.10"
|
||||||
|
|
||||||
- name: apt install
|
- name: apt install
|
||||||
run: |
|
run: |
|
||||||
@@ -46,6 +46,7 @@ jobs:
|
|||||||
|
|
||||||
- name: pip install
|
- name: pip install
|
||||||
run: |
|
run: |
|
||||||
|
pip install --upgrade pip
|
||||||
cd $GITHUB_WORKSPACE
|
cd $GITHUB_WORKSPACE
|
||||||
pip install -r test-requirements.txt
|
pip install -r test-requirements.txt
|
||||||
sudo rm -rf /usr/lib/python3/dist-packages/pytz/
|
sudo rm -rf /usr/lib/python3/dist-packages/pytz/
|
||||||
|
@@ -6,5 +6,10 @@ if __name__ == "__main__":
|
|||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "seahub.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "seahub.settings")
|
||||||
|
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
if not settings.configured:
|
||||||
|
import django
|
||||||
|
django.setup()
|
||||||
|
|
||||||
execute_from_command_line(sys.argv)
|
execute_from_command_line(sys.argv)
|
||||||
|
@@ -1,31 +1,31 @@
|
|||||||
Django==4.2.*
|
Django==5.2.*
|
||||||
django-statici18n==2.5.*
|
django-statici18n==2.6.*
|
||||||
django_webpack_loader==1.7.*
|
django_webpack_loader==1.7.*
|
||||||
django_picklefield==3.2.*
|
django_picklefield==3.3.*
|
||||||
django_formtools==2.5.*
|
django_formtools==2.5.*
|
||||||
django_simple_captcha==0.6.*
|
django_simple_captcha==0.6.*
|
||||||
djangosaml2==1.9.*
|
djangosaml2==1.11.*
|
||||||
djangorestframework==3.15.*
|
djangorestframework==3.16.*
|
||||||
python-dateutil==2.9.*
|
python-dateutil==2.9.*
|
||||||
pyjwt==2.9.*
|
pyjwt==2.10.*
|
||||||
pycryptodome==3.20.*
|
pycryptodome==3.23.*
|
||||||
python-cas==1.6.*
|
python-cas==1.6.*
|
||||||
pysaml2==7.3.*
|
pysaml2==7.5.*
|
||||||
requests==2.32.*
|
requests==2.32.*
|
||||||
requests_oauthlib==2.0.*
|
requests_oauthlib==2.0.*
|
||||||
future==1.0.*
|
future==1.0.*
|
||||||
gunicorn==23.0.*
|
gunicorn==23.0.*
|
||||||
mysqlclient==2.2.*
|
mysqlclient==2.2.*
|
||||||
qrcode==7.4.*
|
qrcode==8.2.*
|
||||||
pillow==10.4.*
|
pillow==11.3.*
|
||||||
chardet==5.2.*
|
chardet==5.2.*
|
||||||
cffi==1.17.0
|
cffi==1.17.1
|
||||||
captcha==0.6.*
|
captcha==0.7.*
|
||||||
openpyxl==3.1.*
|
openpyxl==3.1.*
|
||||||
Markdown==3.6.*
|
Markdown==3.8.*
|
||||||
bleach==5.0.*
|
bleach==5.0.*
|
||||||
python-ldap==3.4.*
|
python-ldap==3.4.*
|
||||||
pypinyin==0.52.*
|
pypinyin==0.55.*
|
||||||
dnspython==2.6.*
|
dnspython==2.7.*
|
||||||
pillow-heif==0.18.*
|
pillow-heif==1.0.*
|
||||||
redis==5.0.*
|
redis==6.2.*
|
||||||
|
@@ -25,6 +25,7 @@ class LazyUser(object):
|
|||||||
|
|
||||||
|
|
||||||
class AuthenticationMiddleware(MiddlewareMixin):
|
class AuthenticationMiddleware(MiddlewareMixin):
|
||||||
|
async_mode = False
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
assert hasattr(
|
assert hasattr(
|
||||||
request, 'session'
|
request, 'session'
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2012-2016 Seafile Ltd.
|
# Copyright (c) 2012-2016 Seafile Ltd.
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.files.storage import default_storage, get_storage_class
|
from django.core.files.storage import default_storage
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
from seahub.base.accounts import User
|
from seahub.base.accounts import User
|
||||||
@@ -112,6 +112,7 @@ def get_primary_avatar(user, size=AVATAR_DEFAULT_SIZE):
|
|||||||
avatar.create_thumbnail(size)
|
avatar.create_thumbnail(size)
|
||||||
return avatar
|
return avatar
|
||||||
|
|
||||||
|
from django.utils.module_loading import import_string
|
||||||
def get_avatar_file_storage():
|
def get_avatar_file_storage():
|
||||||
"""Get avatar file storage, defaults to file system storage.
|
"""Get avatar file storage, defaults to file system storage.
|
||||||
"""
|
"""
|
||||||
@@ -125,4 +126,4 @@ def get_avatar_file_storage():
|
|||||||
'data_column': 'data',
|
'data_column': 'data',
|
||||||
'size_column': 'size',
|
'size_column': 'size',
|
||||||
}
|
}
|
||||||
return get_storage_class(AVATAR_FILE_STORAGE)(options=dbs_options)
|
return import_string(AVATAR_FILE_STORAGE or settings.STORAGES['default'])(options=dbs_options)
|
||||||
|
@@ -34,7 +34,7 @@ class BaseMiddleware(MiddlewareMixin):
|
|||||||
"""
|
"""
|
||||||
Middleware that add organization, group info to user.
|
Middleware that add organization, group info to user.
|
||||||
"""
|
"""
|
||||||
|
async_mode = False
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
|
|
||||||
username = request.user.username
|
username = request.user.username
|
||||||
@@ -84,7 +84,7 @@ class BaseMiddleware(MiddlewareMixin):
|
|||||||
|
|
||||||
class InfobarMiddleware(MiddlewareMixin):
|
class InfobarMiddleware(MiddlewareMixin):
|
||||||
"""Query info bar close status, and store into request."""
|
"""Query info bar close status, and store into request."""
|
||||||
|
async_mode = False
|
||||||
def get_from_db(self):
|
def get_from_db(self):
|
||||||
ret = Notification.objects.all().filter(primary=1)
|
ret = Notification.objects.all().filter(primary=1)
|
||||||
refresh_cache()
|
refresh_cache()
|
||||||
@@ -119,6 +119,7 @@ class InfobarMiddleware(MiddlewareMixin):
|
|||||||
|
|
||||||
|
|
||||||
class ForcePasswdChangeMiddleware(MiddlewareMixin):
|
class ForcePasswdChangeMiddleware(MiddlewareMixin):
|
||||||
|
async_mode = False
|
||||||
def _request_in_black_list(self, request):
|
def _request_in_black_list(self, request):
|
||||||
path = request.path
|
path = request.path
|
||||||
black_list = (r'^%s$' % SITE_ROOT, r'home/.+', r'repo/.+',
|
black_list = (r'^%s$' % SITE_ROOT, r'home/.+', r'repo/.+',
|
||||||
@@ -164,6 +165,7 @@ class UserAgentMiddleWare(MiddlewareMixin):
|
|||||||
user_agents_android_search = u"(?:android)"
|
user_agents_android_search = u"(?:android)"
|
||||||
user_agents_mobile_search = u"(?:mobile)"
|
user_agents_mobile_search = u"(?:mobile)"
|
||||||
user_agents_tablets_search = u"(?:%s)" % u'|'.join(('ipad', 'tablet', ))
|
user_agents_tablets_search = u"(?:%s)" % u'|'.join(('ipad', 'tablet', ))
|
||||||
|
async_mode = False
|
||||||
|
|
||||||
def __init__(self, get_response=None):
|
def __init__(self, get_response=None):
|
||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
|
@@ -7,6 +7,7 @@ from .handlers import get_password_hash, PASSWORD_HASH_KEY
|
|||||||
|
|
||||||
class CheckPasswordHash(MiddlewareMixin):
|
class CheckPasswordHash(MiddlewareMixin):
|
||||||
"""Logout user if value of hash key in session is not equal to current password hash"""
|
"""Logout user if value of hash key in session is not equal to current password hash"""
|
||||||
|
async_mode = False
|
||||||
def process_view(self, request, *args, **kwargs):
|
def process_view(self, request, *args, **kwargs):
|
||||||
if getattr(request.user, 'is_authenticated') and request.user.is_authenticated:
|
if getattr(request.user, 'is_authenticated') and request.user.is_authenticated:
|
||||||
if request.user.enc_password == '!':
|
if request.user.enc_password == '!':
|
||||||
|
@@ -7,8 +7,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from seaserv import FILE_SERVER_PORT
|
FILE_SERVER_PORT = '8082'
|
||||||
|
|
||||||
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)
|
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
@@ -104,12 +103,14 @@ WEBPACK_LOADER = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
|
STORAGES = {
|
||||||
# STORAGES = {
|
"default": {
|
||||||
# "staticfiles": {
|
"BACKEND": 'django.core.files.storage.FileSystemStorage'
|
||||||
# "BACKEND": 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage',
|
},
|
||||||
# },
|
"staticfiles": {
|
||||||
# }
|
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# StaticI18N config
|
# StaticI18N config
|
||||||
STATICI18N_ROOT = '%s/static/scripts' % PROJECT_ROOT
|
STATICI18N_ROOT = '%s/static/scripts' % PROJECT_ROOT
|
||||||
@@ -158,6 +159,7 @@ CSRF_COOKIE_NAME = 'sfcsrftoken'
|
|||||||
# Python dotted path to the WSGI application used by Django's runserver.
|
# Python dotted path to the WSGI application used by Django's runserver.
|
||||||
WSGI_APPLICATION = 'seahub.wsgi.application'
|
WSGI_APPLICATION = 'seahub.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
@@ -177,7 +179,7 @@ TEMPLATES = [
|
|||||||
'seahub.auth.context_processors.auth',
|
'seahub.auth.context_processors.auth',
|
||||||
'seahub.base.context_processors.base',
|
'seahub.base.context_processors.base',
|
||||||
'seahub.base.context_processors.debug',
|
'seahub.base.context_processors.debug',
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -1133,7 +1135,7 @@ def load_local_settings(module):
|
|||||||
module.FILE_SERVER_ROOT = module.HTTP_SERVER_ROOT
|
module.FILE_SERVER_ROOT = module.HTTP_SERVER_ROOT
|
||||||
del module.HTTP_SERVER_ROOT
|
del module.HTTP_SERVER_ROOT
|
||||||
for attr in dir(module):
|
for attr in dir(module):
|
||||||
match = re.search('^EXTRA_(\w+)', attr)
|
match = re.search(r'^EXTRA_(\w+)', attr)
|
||||||
if match:
|
if match:
|
||||||
name = match.group(1)
|
name = match.group(1)
|
||||||
value = getattr(module, attr)
|
value = getattr(module, attr)
|
||||||
@@ -1380,5 +1382,3 @@ if ENABLE_LDAP:
|
|||||||
# ]
|
# ]
|
||||||
|
|
||||||
# settings.py
|
# settings.py
|
||||||
|
|
||||||
|
|
||||||
|
@@ -201,8 +201,18 @@ class FileTagManager(models.Manager):
|
|||||||
|
|
||||||
|
|
||||||
########## Model
|
########## Model
|
||||||
|
class Char32UUIDField(models.UUIDField):
|
||||||
|
def db_type(self, connection):
|
||||||
|
return "char(32)"
|
||||||
|
|
||||||
|
def get_db_prep_value(self, value, connection, prepared=False):
|
||||||
|
value = super().get_db_prep_value(value, connection, prepared)
|
||||||
|
if value is not None:
|
||||||
|
value = value.hex
|
||||||
|
return value
|
||||||
|
|
||||||
class FileUUIDMap(models.Model):
|
class FileUUIDMap(models.Model):
|
||||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4)
|
uuid = Char32UUIDField(primary_key=True, default=uuid.uuid4)
|
||||||
repo_id = models.CharField(max_length=36, db_index=True)
|
repo_id = models.CharField(max_length=36, db_index=True)
|
||||||
repo_id_parent_path_md5 = models.CharField(max_length=100, db_index=True)
|
repo_id_parent_path_md5 = models.CharField(max_length=100, db_index=True)
|
||||||
parent_path = models.TextField()
|
parent_path = models.TextField()
|
||||||
|
@@ -11,6 +11,7 @@ from seahub.settings import ENABLE_LIMIT_IPADDRESS, TRUSTED_IP_LIST
|
|||||||
|
|
||||||
|
|
||||||
class LimitIpMiddleware(MiddlewareMixin):
|
class LimitIpMiddleware(MiddlewareMixin):
|
||||||
|
async_mode = False
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
if not ENABLE_LIMIT_IPADDRESS:
|
if not ENABLE_LIMIT_IPADDRESS:
|
||||||
return None
|
return None
|
||||||
|
@@ -33,6 +33,7 @@ class OTPMiddleware(MiddlewareMixin):
|
|||||||
verified. As a convenience, this also installs ``user.is_verified()``,
|
verified. As a convenience, this also installs ``user.is_verified()``,
|
||||||
which returns ``True`` if ``user.otp_device`` is not ``None``.
|
which returns ``True`` if ``user.otp_device`` is not ``None``.
|
||||||
"""
|
"""
|
||||||
|
async_mode = False
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
if not config.ENABLE_TWO_FACTOR_AUTH:
|
if not config.ENABLE_TWO_FACTOR_AUTH:
|
||||||
return None
|
return None
|
||||||
|
@@ -28,7 +28,7 @@ SEAHUB_TESTSDIR=$(python -c "import os; print(os.path.dirname(os.path.realpath('
|
|||||||
SEAHUB_SRCDIR=$(dirname "${SEAHUB_TESTSDIR}")
|
SEAHUB_SRCDIR=$(dirname "${SEAHUB_TESTSDIR}")
|
||||||
|
|
||||||
export SEAHUB_LOG_DIR='/tmp/logs'
|
export SEAHUB_LOG_DIR='/tmp/logs'
|
||||||
export PYTHONPATH="/usr/local/lib/python3.8/site-packages:/usr/local/lib/python3.8/dist-packages:/usr/lib/python3.8/site-packages:/usr/lib/python3.8/dist-packages:${SEAHUB_SRCDIR}/thirdpart:${PYTHONPATH}"
|
export PYTHONPATH="/usr/local/lib/python3.10/site-packages:/usr/local/lib/python3.10/dist-packages:/usr/lib/python3.10/site-packages:/usr/lib/python3.10/dist-packages:${SEAHUB_SRCDIR}/thirdpart:${PYTHONPATH}"
|
||||||
cd "$SEAHUB_SRCDIR"
|
cd "$SEAHUB_SRCDIR"
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ class TermsAndConditionsRedirectMiddleware(MiddlewareMixin):
|
|||||||
This middleware checks to see if the user is logged in, and if so,
|
This middleware checks to see if the user is logged in, and if so,
|
||||||
if they have accepted the site terms.
|
if they have accepted the site terms.
|
||||||
"""
|
"""
|
||||||
|
async_mode = False
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
"""Process each request to app to ensure terms have been accepted"""
|
"""Process each request to app to ensure terms have been accepted"""
|
||||||
if not config.ENABLE_TERMS_AND_CONDITIONS:
|
if not config.ENABLE_TERMS_AND_CONDITIONS:
|
||||||
|
Reference in New Issue
Block a user