mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 16:41:56 +00:00
部分信息放入 custom_settings 里面
This commit is contained in:
parent
480050fac3
commit
78017df6b6
3
.gitignore
vendored
3
.gitignore
vendored
@ -63,4 +63,5 @@ build.txt
|
||||
tmp/
|
||||
test_case/
|
||||
release/
|
||||
upload/
|
||||
upload/
|
||||
custom_settings.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:
|
||||
|
17
oj/custom_settings.example.py
Normal file
17
oj/custom_settings.example.py
Normal file
@ -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学院<a href=\"http://www.miibeian.gov.cn/\">京ICP备xxxxx号-1</a>",
|
||||
"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}
|
@ -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"青岛大学信息工程学院 创新实验室 <a href=\"http://www.miibeian.gov.cn/\">京ICP备15062075号-1</a>",
|
||||
"url": "https://qduoj.com"}
|
||||
|
||||
|
||||
SMTP_CONFIG = {"smtp_server": "smtp.mxhichina.com",
|
||||
"email": "noreply@qduoj.com",
|
||||
"password": os.environ.get("smtp_password", "111111"),
|
||||
"tls": False}
|
||||
|
||||
|
@ -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"青岛大学信息工程学院 创新实验室 <a href=\"http://www.miibeian.gov.cn/\">京ICP备15062075号-1</a>",
|
||||
"url": "https://qduoj.com"}
|
||||
|
||||
|
||||
SMTP_CONFIG = {"smtp_server": "smtp.mxhichina.com",
|
||||
"email": "noreply@qduoj.com",
|
||||
"password": os.environ.get("smtp_password", "111111"),
|
||||
"tls": False}
|
||||
|
@ -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 = (
|
||||
|
@ -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):
|
||||
|
@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
{% load website_info %}
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>青岛大学在线评测平台 - 首页</title>
|
||||
<title>{% show_website_info "website_name" %} - 首页</title>
|
||||
|
||||
<link href="/static/css/fullpage/jquery.fullPage.css" rel="stylesheet">
|
||||
<link rel="shortcut icon" href="/static/img/favicon.ico">
|
||||
@ -125,21 +125,12 @@
|
||||
loopBottom: true
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
var c = 0;
|
||||
|
||||
setInterval(function(){
|
||||
//alert(1);
|
||||
$("#section0").css("background-image", "url(/static/img/index/bg/bg" + (c++ % 4).toString() + ".jpg)")
|
||||
}, 1000)
|
||||
*/
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<span id="name">qduoj</span>
|
||||
<span id="name">{% show_website_info "website_name_shortcut" %}</span>
|
||||
<a href="/problems/">题目</a>
|
||||
<a href="/submissions/">提交</a>
|
||||
<a href="/contests/">比赛</a>
|
||||
@ -158,7 +149,7 @@
|
||||
<div id="fullpage">
|
||||
<div class="section" id="section0">
|
||||
<div class="index-section-text animated bounceInUp">
|
||||
<h1>青岛大学 Online Judge</h1>
|
||||
<h1>{% show_website_info "website_name" %}</h1>
|
||||
|
||||
<h3>新的面貌,新的开始~</h3>
|
||||
</div>
|
||||
|
@ -77,7 +77,7 @@
|
||||
{% endif %}
|
||||
<textarea class="form-control" id="share-code-textarea"
|
||||
{% if not submission.shared %}style="display: none" {% endif %}>{{ problem.title }}
|
||||
{{ request.build_absolute_uri }}</textarea>
|
||||
{{ website_base_url }}/submission/{{ submission.id }}/</textarea>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
{% load website_info %}
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
@ -8,7 +9,7 @@
|
||||
<link rel="shortcut icon" href="/static/img/favicon.ico">
|
||||
<title>
|
||||
{% block title %}
|
||||
在线评测系统
|
||||
{% show_website_info "website_name" %}
|
||||
{% endblock %}
|
||||
</title>
|
||||
|
||||
@ -20,7 +21,7 @@
|
||||
{% block css_block %}{% endblock %}
|
||||
<!-- custom css end -->
|
||||
</head>
|
||||
{% load website_info %}
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
@ -40,7 +41,7 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">{% show_website_info "website_name" %}</a>
|
||||
<a class="navbar-brand" href="/">{% show_website_info "website_name_shortcut" %}</a>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
@ -49,7 +50,6 @@
|
||||
<li><a href="/contests/">比赛</a></li>
|
||||
<li><a href="/groups/">小组</a></li>
|
||||
<li><a href="/about/">关于</a></li>
|
||||
<li><a href="http://form.mikecrm.com/f.php?t=lREqa0">反馈</a></li>
|
||||
</ul>
|
||||
{% if request.user.is_authenticated %}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
@ -19,55 +19,16 @@
|
||||
经过30多年的发展,ACM国际大学生程序设计竞赛已经发展成为最具影响力的大学生计算机竞赛。赛事目前由IBM公司赞助。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
青岛大学 ACM 队是一支优秀的队伍,一支充满活力与激情的队伍,它满载着光辉与荣誉。在过去的几年里,集训队的队员曾代表我校多次参加竞赛,获得了佳绩。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
ACM 队会在每月举行一次 ACM 月赛,该比赛是 ACM 选拨队员的重要评据。ACM 队用比赛来保证队伍的活力,以比拼来加强队伍的素质,
|
||||
正是如此,ACM 队的队员在程序设计方面始几乎终代表着全院的最高水平。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
如果你有意加入这支优秀的队伍,就用你的行动来证明你的优秀吧,月赛将是你展示自我的舞台。
|
||||
</p>
|
||||
|
||||
<!-- 请使用这套程序的朋友不要删除"开源"这部分 -->
|
||||
<h2 class="text-center">开源</h2>
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/QingdaoU/OnlineJudge" target="_blank">代码</a>
|
||||
<a href="https://github.com/QingdaoU/OnlineJudge" target="_blank">GitHub</a>
|
||||
<a href="https://github.com/QingdaoU/OnlineJudge/issues" target="_blank">问题反馈</a>
|
||||
<a href="https://github.com/QingdaoU/OnlineJudge/wiki/dev-team" target="_blank">开发团队</a>
|
||||
</p>
|
||||
<!-- end -->
|
||||
|
||||
<h2 class="text-center">开发人员</h2>
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>指导老师</th>
|
||||
<th>李建波</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>v1.0</th>
|
||||
<th>
|
||||
董延鑫
|
||||
邢兆龙
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>v2.0</th>
|
||||
<th>
|
||||
董延鑫
|
||||
杨玉飞
|
||||
徐可飞
|
||||
王波
|
||||
周鲁晓
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>v3.0</th>
|
||||
<th>。。。</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
61
tools/run.py
61
tools/run.py
@ -1,61 +0,0 @@
|
||||
# coding=utf-8
|
||||
import os
|
||||
import json
|
||||
|
||||
os.system("docker rm -f redis")
|
||||
os.system("docker rm -f mysql")
|
||||
os.system("docker rm -f oj_web_server")
|
||||
|
||||
if os.system("docker run --name mysql -v /root/data:/var/lib/mysql -v /root/data/my.cnf:/etc/my.cnf -e MYSQL_ROOT_PASSWORD=root -d mysql/mysql-server:latest"):
|
||||
print "Error start mysql"
|
||||
exit()
|
||||
|
||||
if os.system("docker run --name redis -v /root/redis/:/data -d redis redis-server --appendonly yes"):
|
||||
print "Error start redis"
|
||||
exit()
|
||||
|
||||
if os.system("docker run --name oj_web_server -e oj_env=server -v /root/qduoj:/code -v /root/test_case:/code/test_case -v /root/log:/code/log -v /root/upload:/code/upload -v /root/qduoj/dockerfiles/oj_web_server/supervisord.conf:/etc/supervisord.conf -v /root/qduoj/dockerfiles/oj_web_server/gunicorn.conf:/etc/gunicorn.conf -v /root/qduoj/dockerfiles/oj_web_server/mq.conf:/etc/mq.conf -d -p 127.0.0.1:8080:8080 --link mysql --link=redis oj_web_server"):
|
||||
print "Erro start oj_web_server"
|
||||
exit()
|
||||
|
||||
inspect_redis = json.loads(os.popen("docker inspect redis").read())
|
||||
|
||||
if not inspect_redis:
|
||||
print "Error when inspect redis ip"
|
||||
exit()
|
||||
|
||||
redis_ip = inspect_redis[0]["NetworkSettings"]["IPAddress"]
|
||||
print "redis ip ", redis_ip
|
||||
|
||||
|
||||
inspect_mysql = json.loads(os.popen("docker inspect mysql").read())
|
||||
if not inspect_mysql:
|
||||
print "Error when inspect mysql ip"
|
||||
exit()
|
||||
|
||||
mysql_ip = inspect_mysql[0]["NetworkSettings"]["IPAddress"]
|
||||
print "mysql ip ", mysql_ip
|
||||
|
||||
|
||||
f = open("/etc/profile", "r")
|
||||
content = ""
|
||||
for line in f.readlines():
|
||||
if line.startswith("export REDIS_PORT_6379_TCP_ADDR"):
|
||||
content += ("\nexport REDIS_PORT_6379_TCP_ADDR=" + redis_ip + "\n")
|
||||
elif line.startswith("export submission_db_host"):
|
||||
content += ("\nexport submission_db_host=" + mysql_ip + "\n")
|
||||
else:
|
||||
content += line
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
f = open("/etc/profile", "w")
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
||||
print "Please run source /etc/profile"
|
||||
|
||||
os.system("ps -ef|grep celery")
|
||||
print "nohup celery -A judge.judger_controller worker -l DEBUG &"
|
||||
|
Loading…
Reference in New Issue
Block a user