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/setup-python@v4
|
||||
with:
|
||||
python-version: "3.8"
|
||||
python-version: "3.10"
|
||||
|
||||
- name: apt install
|
||||
run: |
|
||||
@@ -46,6 +46,7 @@ jobs:
|
||||
|
||||
- name: pip install
|
||||
run: |
|
||||
pip install --upgrade pip
|
||||
cd $GITHUB_WORKSPACE
|
||||
pip install -r test-requirements.txt
|
||||
sudo rm -rf /usr/lib/python3/dist-packages/pytz/
|
||||
|
@@ -6,5 +6,10 @@ if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "seahub.settings")
|
||||
|
||||
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)
|
||||
|
@@ -1,31 +1,31 @@
|
||||
Django==4.2.*
|
||||
django-statici18n==2.5.*
|
||||
Django==5.2.*
|
||||
django-statici18n==2.6.*
|
||||
django_webpack_loader==1.7.*
|
||||
django_picklefield==3.2.*
|
||||
django_picklefield==3.3.*
|
||||
django_formtools==2.5.*
|
||||
django_simple_captcha==0.6.*
|
||||
djangosaml2==1.9.*
|
||||
djangorestframework==3.15.*
|
||||
djangosaml2==1.11.*
|
||||
djangorestframework==3.16.*
|
||||
python-dateutil==2.9.*
|
||||
pyjwt==2.9.*
|
||||
pycryptodome==3.20.*
|
||||
pyjwt==2.10.*
|
||||
pycryptodome==3.23.*
|
||||
python-cas==1.6.*
|
||||
pysaml2==7.3.*
|
||||
pysaml2==7.5.*
|
||||
requests==2.32.*
|
||||
requests_oauthlib==2.0.*
|
||||
future==1.0.*
|
||||
gunicorn==23.0.*
|
||||
mysqlclient==2.2.*
|
||||
qrcode==7.4.*
|
||||
pillow==10.4.*
|
||||
qrcode==8.2.*
|
||||
pillow==11.3.*
|
||||
chardet==5.2.*
|
||||
cffi==1.17.0
|
||||
captcha==0.6.*
|
||||
cffi==1.17.1
|
||||
captcha==0.7.*
|
||||
openpyxl==3.1.*
|
||||
Markdown==3.6.*
|
||||
Markdown==3.8.*
|
||||
bleach==5.0.*
|
||||
python-ldap==3.4.*
|
||||
pypinyin==0.52.*
|
||||
dnspython==2.6.*
|
||||
pillow-heif==0.18.*
|
||||
redis==5.0.*
|
||||
pypinyin==0.55.*
|
||||
dnspython==2.7.*
|
||||
pillow-heif==1.0.*
|
||||
redis==6.2.*
|
||||
|
@@ -25,6 +25,7 @@ class LazyUser(object):
|
||||
|
||||
|
||||
class AuthenticationMiddleware(MiddlewareMixin):
|
||||
async_mode = False
|
||||
def process_request(self, request):
|
||||
assert hasattr(
|
||||
request, 'session'
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# Copyright (c) 2012-2016 Seafile Ltd.
|
||||
from django.conf import settings
|
||||
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 seahub.base.accounts import User
|
||||
@@ -112,6 +112,7 @@ def get_primary_avatar(user, size=AVATAR_DEFAULT_SIZE):
|
||||
avatar.create_thumbnail(size)
|
||||
return avatar
|
||||
|
||||
from django.utils.module_loading import import_string
|
||||
def get_avatar_file_storage():
|
||||
"""Get avatar file storage, defaults to file system storage.
|
||||
"""
|
||||
@@ -125,4 +126,4 @@ def get_avatar_file_storage():
|
||||
'data_column': 'data',
|
||||
'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.
|
||||
"""
|
||||
|
||||
async_mode = False
|
||||
def process_request(self, request):
|
||||
|
||||
username = request.user.username
|
||||
@@ -84,7 +84,7 @@ class BaseMiddleware(MiddlewareMixin):
|
||||
|
||||
class InfobarMiddleware(MiddlewareMixin):
|
||||
"""Query info bar close status, and store into request."""
|
||||
|
||||
async_mode = False
|
||||
def get_from_db(self):
|
||||
ret = Notification.objects.all().filter(primary=1)
|
||||
refresh_cache()
|
||||
@@ -119,6 +119,7 @@ class InfobarMiddleware(MiddlewareMixin):
|
||||
|
||||
|
||||
class ForcePasswdChangeMiddleware(MiddlewareMixin):
|
||||
async_mode = False
|
||||
def _request_in_black_list(self, request):
|
||||
path = request.path
|
||||
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_mobile_search = u"(?:mobile)"
|
||||
user_agents_tablets_search = u"(?:%s)" % u'|'.join(('ipad', 'tablet', ))
|
||||
async_mode = False
|
||||
|
||||
def __init__(self, get_response=None):
|
||||
self.get_response = get_response
|
||||
|
@@ -7,6 +7,7 @@ from .handlers import get_password_hash, PASSWORD_HASH_KEY
|
||||
|
||||
class CheckPasswordHash(MiddlewareMixin):
|
||||
"""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):
|
||||
if getattr(request.user, 'is_authenticated') and request.user.is_authenticated:
|
||||
if request.user.enc_password == '!':
|
||||
|
@@ -7,8 +7,7 @@ import os
|
||||
import re
|
||||
import copy
|
||||
|
||||
from seaserv import FILE_SERVER_PORT
|
||||
|
||||
FILE_SERVER_PORT = '8082'
|
||||
PROJECT_ROOT = os.path.join(os.path.dirname(__file__), os.pardir)
|
||||
|
||||
DEBUG = False
|
||||
@@ -104,12 +103,14 @@ WEBPACK_LOADER = {
|
||||
}
|
||||
}
|
||||
|
||||
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
|
||||
# STORAGES = {
|
||||
# "staticfiles": {
|
||||
# "BACKEND": 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage',
|
||||
# },
|
||||
# }
|
||||
STORAGES = {
|
||||
"default": {
|
||||
"BACKEND": 'django.core.files.storage.FileSystemStorage'
|
||||
},
|
||||
"staticfiles": {
|
||||
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
|
||||
},
|
||||
}
|
||||
|
||||
# StaticI18N config
|
||||
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.
|
||||
WSGI_APPLICATION = 'seahub.wsgi.application'
|
||||
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
@@ -177,7 +179,7 @@ TEMPLATES = [
|
||||
'seahub.auth.context_processors.auth',
|
||||
'seahub.base.context_processors.base',
|
||||
'seahub.base.context_processors.debug',
|
||||
],
|
||||
]
|
||||
},
|
||||
},
|
||||
]
|
||||
@@ -1133,7 +1135,7 @@ def load_local_settings(module):
|
||||
module.FILE_SERVER_ROOT = module.HTTP_SERVER_ROOT
|
||||
del module.HTTP_SERVER_ROOT
|
||||
for attr in dir(module):
|
||||
match = re.search('^EXTRA_(\w+)', attr)
|
||||
match = re.search(r'^EXTRA_(\w+)', attr)
|
||||
if match:
|
||||
name = match.group(1)
|
||||
value = getattr(module, attr)
|
||||
@@ -1380,5 +1382,3 @@ if ENABLE_LDAP:
|
||||
# ]
|
||||
|
||||
# settings.py
|
||||
|
||||
|
||||
|
@@ -201,8 +201,18 @@ class FileTagManager(models.Manager):
|
||||
|
||||
|
||||
########## 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):
|
||||
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_parent_path_md5 = models.CharField(max_length=100, db_index=True)
|
||||
parent_path = models.TextField()
|
||||
|
@@ -11,6 +11,7 @@ from seahub.settings import ENABLE_LIMIT_IPADDRESS, TRUSTED_IP_LIST
|
||||
|
||||
|
||||
class LimitIpMiddleware(MiddlewareMixin):
|
||||
async_mode = False
|
||||
def process_request(self, request):
|
||||
if not ENABLE_LIMIT_IPADDRESS:
|
||||
return None
|
||||
|
@@ -33,6 +33,7 @@ class OTPMiddleware(MiddlewareMixin):
|
||||
verified. As a convenience, this also installs ``user.is_verified()``,
|
||||
which returns ``True`` if ``user.otp_device`` is not ``None``.
|
||||
"""
|
||||
async_mode = False
|
||||
def process_request(self, request):
|
||||
if not config.ENABLE_TWO_FACTOR_AUTH:
|
||||
return None
|
||||
|
@@ -28,7 +28,7 @@ SEAHUB_TESTSDIR=$(python -c "import os; print(os.path.dirname(os.path.realpath('
|
||||
SEAHUB_SRCDIR=$(dirname "${SEAHUB_TESTSDIR}")
|
||||
|
||||
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"
|
||||
set +x
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class TermsAndConditionsRedirectMiddleware(MiddlewareMixin):
|
||||
This middleware checks to see if the user is logged in, and if so,
|
||||
if they have accepted the site terms.
|
||||
"""
|
||||
|
||||
async_mode = False
|
||||
def process_request(self, request):
|
||||
"""Process each request to app to ensure terms have been accepted"""
|
||||
if not config.ENABLE_TERMS_AND_CONDITIONS:
|
||||
|
Reference in New Issue
Block a user