diff --git a/.gitignore b/.gitignore index 8707498f..a3159d42 100644 --- a/.gitignore +++ b/.gitignore @@ -63,4 +63,5 @@ build.txt tmp/ test_case/ release/ -upload/ \ No newline at end of file +upload/ +custom_settings.py \ No newline at end of file diff --git a/account/views.py b/account/views.py index 9c41b349..cf31b158 100644 --- a/account/views.py +++ b/account/views.py @@ -43,7 +43,6 @@ class UserLoginAPIView(APIView): serializer = UserLoginSerializer(data=request.data) if serializer.is_valid(): data = serializer.data - print data user = auth.authenticate(username=data["username"], password=data["password"]) # 用户名或密码错误的话 返回None if user: diff --git a/oj/custom_settings.example.py b/oj/custom_settings.example.py new file mode 100644 index 00000000..a1d10903 --- /dev/null +++ b/oj/custom_settings.example.py @@ -0,0 +1,17 @@ +# coding=utf-8 +import os + +SECRET_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + +SSO = {"callback": "https://xxxxxxxxx/login"} + +WEBSITE_INFO = {"website_name": u"xx大学 OnlineJudge", + "website_name_shortcut": u"qduoj", + "website_footer": u"xx大学xx学院京ICP备xxxxx号-1", + "url": u"https://your-domain.com"} + + +SMTP_CONFIG = {"smtp_server": "smtp.xxx.com", + "email": "noreply@xxx.com", + "password": os.environ.get("smtp_password", "111111"), + "tls": False} diff --git a/oj/local_settings.py b/oj/local_settings.py index 31f5b407..77b1bcae 100644 --- a/oj/local_settings.py +++ b/oj/local_settings.py @@ -3,7 +3,6 @@ import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -45,15 +44,3 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/src/"), BASE_DIR] # 模板文件夹 OJ_TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/src/')] -SSO = {"callback": "http://localhost:8765/login"} - -WEBSITE_INFO = {"website_name": "qduoj", - "website_footer": u"青岛大学信息工程学院 创新实验室 京ICP备15062075号-1", - "url": "https://qduoj.com"} - - -SMTP_CONFIG = {"smtp_server": "smtp.mxhichina.com", - "email": "noreply@qduoj.com", - "password": os.environ.get("smtp_password", "111111"), - "tls": False} - diff --git a/oj/server_settings.py b/oj/server_settings.py index bd0d3041..b09a229b 100644 --- a/oj/server_settings.py +++ b/oj/server_settings.py @@ -3,36 +3,35 @@ import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': "oj", 'CONN_MAX_AGE': 0.1, - 'HOST': os.environ.get("MYSQL_PORT_3306_TCP_ADDR", "127.0.0.1"), + 'HOST': os.environ["MYSQL_PORT_3306_TCP_ADDR"], 'PORT': 3306, - 'USER': os.environ.get("MYSQL_ENV_MYSQL_USER", "root"), - 'PASSWORD': os.environ.get("MYSQL_ENV_MYSQL_ROOT_PASSWORD", "root") + 'USER': os.environ["MYSQL_ENV_MYSQL_USER"], + 'PASSWORD': os.environ["MYSQL_ENV_MYSQL_ROOT_PASSWORD"] }, 'submission': { 'NAME': 'oj_submission', 'ENGINE': 'django.db.backends.mysql', 'CONN_MAX_AGE': 0.1, - 'HOST': os.environ.get("MYSQL_PORT_3306_TCP_ADDR", "127.0.0.1"), + 'HOST': os.environ["MYSQL_PORT_3306_TCP_ADDR"], 'PORT': 3306, - 'USER': os.environ.get("MYSQL_ENV_MYSQL_USER", "root"), - 'PASSWORD': os.environ.get("MYSQL_ENV_MYSQL_ROOT_PASSWORD", "root") + 'USER': os.environ["MYSQL_ENV_MYSQL_USER"], + 'PASSWORD': os.environ["MYSQL_ENV_MYSQL_ROOT_PASSWORD"] } } REDIS_CACHE = { - "host": os.environ.get("REDIS_PORT_6379_TCP_ADDR", "127.0.0.1"), + "host": os.environ["REDIS_PORT_6379_TCP_ADDR"], "port": 6379, "db": 1 } REDIS_QUEUE = { - "host": os.environ.get("REDIS_PORT_6379_TCP_ADDR", "127.0.0.1"), + "host": os.environ["REDIS_PORT_6379_TCP_ADDR"], "port": 6379, "db": 2 } @@ -54,16 +53,4 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/release/"), os.path.join(BASE # 模板文件夹 OJ_TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/release/')] -SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') -SSO = {"callback": "https://discuss.acmer.site/login"} - -WEBSITE_INFO = {"website_name": "qduoj", - "website_footer": u"青岛大学信息工程学院 创新实验室 京ICP备15062075号-1", - "url": "https://qduoj.com"} - - -SMTP_CONFIG = {"smtp_server": "smtp.mxhichina.com", - "email": "noreply@qduoj.com", - "password": os.environ.get("smtp_password", "111111"), - "tls": False} diff --git a/oj/settings.py b/oj/settings.py index e6e53a5d..8d069668 100644 --- a/oj/settings.py +++ b/oj/settings.py @@ -22,6 +22,8 @@ if ENV == "local": elif ENV == "server": from .server_settings import * +from .custom_settings import * + import djcelery djcelery.setup_loader() @@ -31,10 +33,6 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'hzfp^8mbgapc&x%$#xv)0=t8s7_ilingw(q3!@h&2fty6v6fxz' - - # Application definition INSTALLED_APPS = ( diff --git a/submission/views.py b/submission/views.py index 8763e1e3..deb749da 100644 --- a/submission/views.py +++ b/submission/views.py @@ -180,7 +180,7 @@ def my_submission(request, submission_id): user = User.objects.get(id=submission.user_id) return render(request, "oj/submission/my_submission.html", {"submission": submission, "problem": problem, "info": info, - "user": user, "can_share": result["can_share"]}) + "user": user, "can_share": result["can_share"], "website_base_url": settings.WEBSITE_INFO["url"]}) class SubmissionAdminAPIView(APIView): diff --git a/template/src/oj/index.html b/template/src/oj/index.html index 86bf07fd..feef7b46 100644 --- a/template/src/oj/index.html +++ b/template/src/oj/index.html @@ -1,9 +1,9 @@ - +{% load website_info %}
-