-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some functions、Fix some bugs #253
base: master
Are you sure you want to change the base?
Changes from 56 commits
69d487c
b373dae
1d52d6e
db3b3fa
0d354d8
efc4f3f
3242c56
aa5673b
4bd37f9
ccaebba
ee4e9f6
a1b6626
d00648a
7813c2b
522c2fd
a03493f
3c21ab9
5251ef5
1128f62
0e1dc73
80fae07
80e98ba
5df6867
1ec09a4
d8e36a1
22d2ab9
8634151
5370c94
5dbd8ee
0140cce
d64e10f
68cb328
cf6fbdd
2596b31
775ece9
8c6ed1e
9150053
431847e
f606583
4bd5078
c66c31f
bc6ba0e
e53c662
5bd3a7f
0d6880d
4ab80fa
7627199
9b1fc05
13d09cc
12ec4df
79459ab
68eb023
3f7aaf0
1f5dcf4
13fdd1a
6c0cb62
fa273fb
a4a49d9
d827688
226f1da
a7c0d8f
ab3270e
798776d
9ff2324
8720a19
662dd60
7e84802
43a8e39
970dcd5
2bc5112
ed16473
82986de
c1224bb
a1bd341
624fea0
b9cf579
cc43dc7
1cf08f2
7756231
8591798
1bb7197
0d8814d
9bd3fb3
2d8a3c7
62e428d
5721a65
2542b00
5acae1a
e4611f9
2075499
4579d18
7bba8ea
7b0e0d5
267a069
a6a83cf
8a7a1d6
e6ea5d0
5020349
52f4ba0
a80bcdb
464ed5d
f193c5c
77dcfe4
faffd7f
ad43ae7
e696e87
a8d7416
18a024b
2c09460
ef19b30
ab63ed4
73475e7
4462910
1249bb4
d0a5c53
6f6ea3c
eff19aa
020de76
7676ed9
9c58047
6d09da3
e825a16
2ccd75f
ff6bf78
e28a522
65ba399
60e8910
17530c4
8f15bc8
eac6844
dd071bb
d707ab2
c6f9fcd
7d5bbdf
839929a
370bc77
ecb62c2
9df3237
bae5528
cd3c299
a576dc7
c137e0b
07bf2e2
0fac47b
5e42af2
2434ed4
cfed97f
79b72e8
236ae72
9891670
7864fd4
a0fee49
b18f2f8
5dccd3e
59d8df6
7c43429
789b9fb
4c39a68
0a2fb56
0254541
24cd0e4
f3a0579
7fc60f6
7d5bc32
2eb44c9
3c942f4
f4534a5
a3a216c
3b13d7d
1e631e2
dd2a52b
9be5ea8
18d672c
a886e2b
27b29b9
186dad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,34 +3,38 @@ | |
[![Python](https://img.shields.io/badge/python-3.6.2-blue.svg?style=flat-square)](https://www.python.org/downloads/release/python-362/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 整个文件 markdown 标记加号也可以吧 |
||
[![Django](https://img.shields.io/badge/django-1.11.4-blue.svg?style=flat-square)](https://www.djangoproject.com/) | ||
[![Django Rest Framework](https://img.shields.io/badge/django_rest_framework-3.4.0-blue.svg?style=flat-square)](http://www.django-rest-framework.org/) | ||
[![Build Status](https://travis-ci.org/QingdaoU/OnlineJudge.svg?branch=master)](https://travis-ci.org/QingdaoU/OnlineJudge) | ||
[![Build Status](https://travis-ci.org/Harry-zklcdc/OnlineJudge.svg?branch=master)](https://travis-ci.org/Harry-zklcdc/OnlineJudge) | ||
|
||
> #### 基于 Python 和 Vue 的在线评测系统。 [Demo](https://qduoj.com) | ||
> #### 基于 Python 和 Vue 的在线评测系统。 [Demo](http://www.yangzheng.com.cn:84) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 域名 |
||
|
||
[English Document](README.md) | ||
|
||
## 概览 | ||
|
||
+ 基于 Docker,真正一键部署 | ||
+ 前后端分离,模块化编程,微服务 | ||
+ ACM/OI 两种比赛模式、实时/非实时评判 任意选择 | ||
+ 丰富的可视化图表,一图胜千言 | ||
+ 支持 Template Problem,可以添加函数题甚至填空题 | ||
+ 更细致的权限划分,超级管理员和普通管理员各司其职 | ||
+ 多语言支持:`C`, `C++`, `Java`, `Python2`, `Python3`,题目可以选择使用的语言 | ||
+ Markdown & MathJax 支持 | ||
+ 比赛用户IP限制 (CIDR ranges) | ||
- 基于 Docker,真正一键部署 | ||
- 前后端分离,模块化编程,微服务 | ||
- ACM/OI 两种比赛模式、实时/非实时评判 任意选择 | ||
- 丰富的可视化图表,一图胜千言 | ||
- 支持 Template Problem,可以添加函数题甚至填空题 | ||
- 更细致的权限划分,超级管理员和普通管理员各司其职 | ||
- 多语言支持:`C`, `C++`, `Java`, `Python2`, `Python3`,题目可以选择使用的语言 | ||
- Markdown & MathJax 支持 | ||
- 比赛用户IP限制 (CIDR ranges) | ||
- 在线 IDE | ||
- 自定义关于我们介绍页面 | ||
- 换肤功能 | ||
- 标准输入输出 / 文件输入输出 | ||
|
||
主要模块均已开源: | ||
|
||
+ 后端(Django): [https://github.com/QingdaoU/OnlineJudge](https://github.com/QingdaoU/OnlineJudge) | ||
+ 前端(Vue): [https://github.com/QingdaoU/OnlineJudgeFE](https://github.com/QingdaoU/OnlineJudgeFE) | ||
+ 判题沙箱(Seccomp): [https://github.com/QingdaoU/Judger](https://github.com/QingdaoU/Judger) | ||
+ 判题服务器(对Judger的封装): [https://github.com/QingdaoU/JudgeServer](https://github.com/QingdaoU/JudgeServer) | ||
- 后端(Django): [https://github.com/Harry-zklcdc/OnlineJudge](https://github.com/Harry-zklcdc/OnlineJudge) | ||
- 前端(Vue): [https://github.com/Harry-zklcdc/OJ](https://github.com/Harry-zklcdc/OJ) | ||
- 判题沙箱(Seccomp): [https://github.com/Harry-zklcdc/Judger](https://github.com/Harry-zklcdc/Judger) | ||
- 判题服务器(对Judger的封装): [https://github.com/Harry-zklcdc/JudgeServer](https://github.com/Harry-zklcdc/JudgeServe) | ||
|
||
## 安装 | ||
|
||
请根据此进行安装: [https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0](https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0) | ||
请根据此进行安装: [https://github.com/Harry-zklcdc/OnlineJudgeDeploy/tree/2.0](https://github.com/Harry-zklcdc/OnlineJudgeDeploy/tree/2.0) | ||
|
||
## 文档 | ||
|
||
|
@@ -68,15 +72,14 @@ Rankings 中可以控制图表和菜单的显隐。 | |
|
||
![create-contest](https://user-images.githubusercontent.com/20637881/33372514-428ab922-d539-11e7-8f68-da55dedf3ad3.png) | ||
|
||
|
||
## 浏览器支持 | ||
|
||
Modern browsers(chrome, firefox) 和 Internet Explorer 10+. | ||
|
||
## 特别感谢 | ||
|
||
+ 所有为本项目做出贡献的人 | ||
+ [heb1c](https://github.com/hebicheng) 同学为我们提供了很多意见和建议 | ||
- 所有为本项目做出贡献的人 | ||
- [heb1c](https://github.com/hebicheng) 同学为我们提供了很多意见和建议 | ||
|
||
如果您觉得这个项目还不错,就star一下吧 :) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,34 +3,40 @@ | |
[![Python](https://img.shields.io/badge/python-3.6.2-blue.svg?style=flat-square)](https://www.python.org/downloads/release/python-362/) | ||
[![Django](https://img.shields.io/badge/django-1.11.4-blue.svg?style=flat-square)](https://www.djangoproject.com/) | ||
[![Django Rest Framework](https://img.shields.io/badge/django_rest_framework-3.4.0-blue.svg?style=flat-square)](http://www.django-rest-framework.org/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同 README-CN.md |
||
[![Build Status](https://travis-ci.org/QingdaoU/OnlineJudge.svg?branch=master)](https://travis-ci.org/QingdaoU/OnlineJudge) | ||
[![Build Status](https://travis-ci.org/Harry-zklcdc/OnlineJudge.svg?branch=master)](https://travis-ci.org/Harry-zklcdc/OnlineJudge) | ||
|
||
> #### An onlinejudge system based on Python and Vue. [Demo](https://qduoj.com) | ||
> | ||
> | ||
> #### An onlinejudge system based on Python and Vue. [Demo](http://www.yangzheng.com.cn:84) | ||
|
||
[中文文档](README-CN.md) | ||
|
||
## Overview | ||
|
||
+ Based on Docker; One-click deployment | ||
+ Separated backend and frontend; Modular programming; Micro service | ||
+ ACM/OI rule support; realtime/non-realtime rank support | ||
+ Amazing charting and visualization | ||
+ Template-problem support | ||
+ More reasonable permission control | ||
+ Multi-language support: `C`, `C++`, `Java`, `Python2`, `Python3` | ||
+ Markdown & MathJax support | ||
+ Contest participants IP limit(CIDR) | ||
- Based on Docker; One-click deployment | ||
- Separated backend and frontend; Modular programming; Micro service | ||
- ACM/OI rule support; realtime/non-realtime rank support | ||
- Amazing charting and visualization | ||
- Template-problem support | ||
- More reasonable permission control | ||
- Multi-language support: `C`, `C++`, `Java`, `Python2`, `Python3` | ||
- Markdown & MathJax support | ||
- Contest participants IP limit(CIDR) | ||
- Online IDE | ||
- DIY About Us Page | ||
- Optional Theme | ||
- Standard IO/File IO | ||
|
||
Main modules are available below: | ||
|
||
+ Backend(Django): [https://github.com/QingdaoU/OnlineJudge](https://github.com/QingdaoU/OnlineJudge) | ||
+ Frontend(Vue): [https://github.com/QingdaoU/OnlineJudgeFE](https://github.com/QingdaoU/OnlineJudgeFE) | ||
+ Judger Sandbox(Seccomp): [https://github.com/QingdaoU/Judger](https://github.com/QingdaoU/Judger) | ||
+ JudgeServer(A wrapper for Judger): [https://github.com/QingdaoU/JudgeServer](https://github.com/QingdaoU/JudgeServer) | ||
- Backend(Django): [https://github.com/Harry-zklcdc/OnlineJudge](https://github.com/Harry-zklcdc/OnlineJudge) | ||
- Frontend(Vue): [https://github.com/Harry-zklcdc/OJ](https://github.com/Harry-zklcdc/OJ) | ||
- Judger Sandbox(Seccomp): [https://github.com/Harry-zklcdc/Judger](https://github.com/Harry-zklcdc/Judger) | ||
- JudgeServer(A wrapper for Judger): [https://github.com/Harry-zklcdc/JudgeServer](https://github.com/Harry-zklcdc/JudgeServer) | ||
|
||
## Installation | ||
|
||
Follow me: [https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0](https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0) | ||
Follow me: [https://github.com/Harry-zklcdc/OnlineJudgeDeploy/tree/2.0](https://github.com/Harry-zklcdc/OnlineJudgeDeploy/tree/2.0) | ||
|
||
## Documents | ||
|
||
|
@@ -76,10 +82,10 @@ Modern browsers(chrome, firefox) and Internet Explorer 10+. | |
|
||
## Thanks | ||
|
||
+ I'd appreciate a star if you find this helpful. | ||
+ Thanks to everyone that contributes to this project. | ||
+ Special thanks to [heb1c](https://github.com/hebicheng), who has given us a lot of suggestions. | ||
- I'd appreciate a star if you find this helpful. | ||
- Thanks to everyone that contributes to this project. | ||
- Special thanks to [heb1c](https://github.com/hebicheng), who has given us a lot of suggestions. | ||
|
||
## License | ||
|
||
[MIT](http://opensource.org/licenses/MIT) | ||
[MIT](http://opensource.org/licenses/MIT)** |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,11 @@ def get(self, request): | |
user = user.filter(Q(username__icontains=keyword) | | ||
Q(userprofile__real_name__icontains=keyword) | | ||
Q(email__icontains=keyword)) | ||
|
||
only_admin = request.GET.get("onlyadmin", None) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
下面的筛选应该用
https://github.com/QingdaoU/OnlineJudge/blob/master/account/models.py#L7 |
||
if only_admin: | ||
user = user.filter(Q(admin_type__icontains="Admin")) | ||
|
||
return self.success(self.paginate_data(request, user, UserAdminSerializer)) | ||
|
||
@super_admin_required | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ class Migration(migrations.Migration): | |
}, | ||
), | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 多了空行 |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.3 on 2019-04-30 21:18 | ||
from __future__ import unicode_literals | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
import utils.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('announcement', '0003_auto_20180501_0436'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='AboutUs', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('content', utils.models.RichTextField()), | ||
('last_update_time', models.DateTimeField(auto_now=True)), | ||
], | ||
options={ | ||
'db_table': 'aboutus', | ||
}, | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from utils.api import serializers | ||
from utils.api._serializers import UsernameSerializer | ||
|
||
from .models import Announcement | ||
from .models import Announcement, AboutUs | ||
|
||
|
||
class CreateAnnouncementSerializer(serializers.Serializer): | ||
|
@@ -23,3 +23,19 @@ class EditAnnouncementSerializer(serializers.Serializer): | |
title = serializers.CharField(max_length=64) | ||
content = serializers.CharField(max_length=1024 * 1024 * 8) | ||
visible = serializers.BooleanField() | ||
|
||
|
||
class CreateAboutUsSerializer(serializers.Serializer): | ||
content = serializers.CharField(max_length=1024 * 1024 * 8) | ||
|
||
|
||
class AboutUsSerializer(serializers.ModelSerializer): | ||
|
||
class Meta: | ||
model = AboutUs | ||
fields = "__all__" | ||
|
||
|
||
class EditAboutUsSerializer(serializers.Serializer): | ||
id = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. id = 0 没用吧 |
||
content = serializers.CharField(max_length=1024 * 1024 * 8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.conf.urls import url | ||
|
||
from ..views.admin import AnnouncementAdminAPI | ||
from ..views.admin import AnnouncementAdminAPI, AboutUsAdminAPI | ||
|
||
urlpatterns = [ | ||
url(r"^announcement/?$", AnnouncementAdminAPI.as_view(), name="announcement_admin_api"), | ||
url(r"^aboutus/?$", AboutUsAdminAPI.as_view(), name="aboutus_admin_api"), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.conf.urls import url | ||
|
||
from ..views.oj import AnnouncementAPI | ||
from ..views.oj import AnnouncementAPI, AboutUsAPI | ||
|
||
urlpatterns = [ | ||
url(r"^announcement/?$", AnnouncementAPI.as_view(), name="announcement_api"), | ||
url(r"^aboutus/?$", AboutUsAPI.as_view(), name="aboutus_api"), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from account.decorators import super_admin_required | ||
from utils.api import APIView, validate_serializer | ||
|
||
from announcement.models import Announcement | ||
from announcement.serializers import (AnnouncementSerializer, CreateAnnouncementSerializer, | ||
EditAnnouncementSerializer) | ||
from announcement.models import Announcement, AboutUs | ||
from announcement.serializers import (AnnouncementSerializer, CreateAnnouncementSerializer, EditAnnouncementSerializer, | ||
AboutUsSerializer, CreateAboutUsSerializer, EditAboutUsSerializer) | ||
|
||
|
||
class AnnouncementAdminAPI(APIView): | ||
|
@@ -60,3 +60,45 @@ def delete(self, request): | |
if request.GET.get("id"): | ||
Announcement.objects.filter(id=request.GET["id"]).delete() | ||
return self.success() | ||
|
||
|
||
class AboutUsAdminAPI(APIView): | ||
@validate_serializer(CreateAboutUsSerializer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这种全局只会有一条的东西,建议放在 https://github.com/QingdaoU/OnlineJudge/blob/master/options/options.py#L95 OptionKeys OptionDefaultValue _SysOptionsMeta 三个位置各自模仿写一下就可以了,不用单独建一个表 |
||
@super_admin_required | ||
def post(self, request): | ||
""" | ||
publish aboutus | ||
""" | ||
data = request.data | ||
aboutus = AboutUs.objects.create(content=data["content"]) | ||
return self.success(AboutUsSerializer(aboutus).data) | ||
|
||
@validate_serializer(EditAboutUsSerializer) | ||
@super_admin_required | ||
def put(self, request): | ||
""" | ||
edit aboutus | ||
""" | ||
data = request.data | ||
try: | ||
aboutus = AboutUs.objects.get(id=1) | ||
except AboutUs.DoesNotExist: | ||
return self.error("About Us does not exist") | ||
|
||
for k, v in data.items(): | ||
setattr(aboutus, k, v) | ||
aboutus.save() | ||
|
||
return self.success(AboutUsSerializer(aboutus).data) | ||
|
||
@super_admin_required | ||
def get(self, request): | ||
""" | ||
get about_us list / get about_us | ||
""" | ||
aboutus_id = 1 | ||
try: | ||
aboutus = AboutUs.objects.get(id=aboutus_id) | ||
return self.success(AboutUsSerializer(aboutus).data) | ||
except AboutUs.DoesNotExist: | ||
return self.success(None) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
from utils.api import APIView | ||
|
||
from announcement.models import Announcement | ||
from announcement.serializers import AnnouncementSerializer | ||
from announcement.models import Announcement, AboutUs | ||
from announcement.serializers import AnnouncementSerializer, AboutUsSerializer | ||
|
||
|
||
class AnnouncementAPI(APIView): | ||
def get(self, request): | ||
announcements = Announcement.objects.filter(visible=True) | ||
return self.success(self.paginate_data(request, announcements, AnnouncementSerializer)) | ||
|
||
|
||
class AboutUsAPI(APIView): | ||
def get(self, request): | ||
try: | ||
aboutus = AboutUs.objects.get(id=1) | ||
return self.success(AboutUsSerializer(aboutus).data) | ||
except AboutUs.DoesNotExist: | ||
return self.error("About Us does not exist") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
域名