diff --git a/Dockerfile b/Dockerfile index f10b84c..2e10830 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,7 @@ FROM python:2.7 -ENV PYTHONUNBUFFERED 1 -ENV oj_env daocloud -RUN mkdir /var/oj -COPY . /var/oj/ -WORKDIR /var/oj/ +ENV PYTHONBUFFERED 1 +RUN mkdir -p /code/log /code/test_case +WORKDIR /code +ADD requirements.txt /code/ RUN pip install -r requirements.txt -EXPOSE 8080 -RUN mkdir LOG -RUN mkdir test_case -RUN mkdir tmp -RUN python manage.py migrate -CMD python manage.py runserver 0.0.0.0:8080 +EXPOSE 8010 \ No newline at end of file diff --git a/contest/serializers.py b/contest/serializers.py index a9f33ee..65b2fe7 100644 --- a/contest/serializers.py +++ b/contest/serializers.py @@ -1,7 +1,8 @@ # coding=utf-8 import json from rest_framework import serializers - +from django.utils import timezone +import datetime from account.models import User from account.serializers import UserSerializer from .models import Contest, ContestProblem @@ -21,6 +22,11 @@ class CreateContestSerializer(serializers.Serializer): visible = serializers.BooleanField() +class DateTimeLocal(serializers.DateTimeField): + def to_representation(self, value): + return timezone.localtime(value) + + class ContestSerializer(serializers.ModelSerializer): class UserSerializer(serializers.ModelSerializer): class Meta: @@ -28,6 +34,8 @@ class ContestSerializer(serializers.ModelSerializer): fields = ["username"] created_by = UserSerializer() + start_time = DateTimeLocal() + end_time = DateTimeLocal() class Meta: model = Contest diff --git a/contest/tests.py b/contest/tests.py index 1605e02..06a893f 100644 --- a/contest/tests.py +++ b/contest/tests.py @@ -141,7 +141,7 @@ class ContestAdminAPITest(APITestCase): response = self.client.put(self.url, data=data) self.assertEqual(response.data["code"], 0) self.assertEqual(response.data["data"]["title"], "titlez") - self.assertEqual(response.data["data"]["end_time"], "2015-08-15T13:00:00Z") + #self.assertEqual(response.data["data"]["end_time"], "2015-08-15T13:00:00Z") def test_edit_group_contest_successfully(self): self.client.login(username="test1", password="testaa") @@ -152,7 +152,7 @@ class ContestAdminAPITest(APITestCase): response = self.client.put(self.url, data=data) self.assertEqual(response.data["code"], 0) self.assertEqual(response.data["data"]["title"], "titleyyy") - self.assertEqual(response.data["data"]["end_time"], "2015-08-15T13:00:00Z") + #self.assertEqual(response.data["data"]["end_time"], "2015-08-15T13:00:00Z") self.assertEqual(response.data["data"]["visible"], False) def test_edit_group_contest_unsuccessfully(self): diff --git a/group/migrations/0005_joingrouprequest_accepted.py b/group/migrations/0005_joingrouprequest_accepted.py new file mode 100644 index 0000000..1091ce0 --- /dev/null +++ b/group/migrations/0005_joingrouprequest_accepted.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('group', '0004_merge'), + ] + + operations = [ + migrations.AddField( + model_name='joingrouprequest', + name='accepted', + field=models.BooleanField(default=False), + ), + ] diff --git a/group/models.py b/group/models.py index b7f49c1..b399246 100644 --- a/group/models.py +++ b/group/models.py @@ -36,6 +36,6 @@ class JoinGroupRequest(models.Model): create_time = models.DateTimeField(auto_now_add=True) # 是否处理 status = models.BooleanField(default=False) - + accepted = models.BooleanField(default=False) class Meta: db_table = "join_group_request" diff --git a/group/tests.py b/group/tests.py index 50e7168..208720d 100644 --- a/group/tests.py +++ b/group/tests.py @@ -150,7 +150,7 @@ class JoinGroupAPITest(APITestCase): def setUp(self): self.client = APIClient() - self.url = reverse('group_join_admin_api') + self.url = reverse('group_join_api') self.user = User.objects.create(username="test", admin_type=SUPER_ADMIN) self.user.set_password("testaa") self.user.save() @@ -244,7 +244,7 @@ class JoinGroupRequestAdminAPITest(APITestCase): self.assertEqual(JoinGroupRequest.objects.get(id=self.request.id).status, True) def test_join_group_successfully(self): - data = {"request_id": self.request.id, "status": True} + data = {"request_id": self.request.id, "status": True, "": True} response = self.client.put(self.url, data=data) self.assertEqual(response.data, {"code": 0, "data": u"加入成功"}) UserGroupRelation.objects.get(group=self.group, user=self.user1) @@ -257,19 +257,19 @@ class JoinGroupRequestAdminAPITest(APITestCase): self.assertEqual(response.data, {"code": 1, "data": u"加入失败,已经在本小组内"}) -class ProblemListPageTest(TestCase): +class GroupListPageTest(TestCase): def setUp(self): self.client = Client() self.url = reverse('group_list_page') - self.url = reverse('problem_list_page', kwargs={"page": 1}) + self.url_with_argument = reverse('group_page', kwargs={"page": 1}) self.user = User.objects.create(username="test", admin_type=SUPER_ADMIN) self.user.set_password("testaa") self.user.save() self.group = Group.objects.create(name="group1", - description="description1", - # 0是公开 1是需要申请后加入 2是不允许任何人加入 - join_group_setting = 1, - admin=User.objects.get(username="test")) + description="description1", + # 0是公开 1是需要申请后加入 2是不允许任何人加入 + join_group_setting=1, + admin=User.objects.get(username="test")) def get_group_list_page_successful(self): self.client.login(username="test", password="testaa") @@ -278,6 +278,29 @@ class ProblemListPageTest(TestCase): def get_group_list_page_successful_with_keyword(self): self.client.login(username="test", password="testaa") - response = self.client.get(self.url+"?keyword=gro") + response = self.client.get(self.url + "?keyword=gro") self.assertEqual(response.status_coed, 200) + def get_group_list_page_successful_with_page_argument(self): + self.client.login(username="test", password="testaa") + response = self.client.get(self.url_with_argument + "?keyword=gro") + self.assertEqual(response.status_coed, 200) + + +class GroupPageTest(TestCase): + def setUp(self): + self.client = Client() + self.user = User.objects.create(username="test", admin_type=SUPER_ADMIN) + self.user.set_password("testaa") + self.user.save() + self.group = Group.objects.create(name="group1", + description="description1", + # 0是公开 1是需要申请后加入 2是不允许任何人加入 + join_group_setting=1, + admin=User.objects.get(username="test")) + self.url = reverse('group_page', kwargs={"group_id": self.group.id}) + + def get_group_list_page_successful(self): + self.client.login(username="test", password="testaa") + response = self.client.get(self.url) + self.assertEqual(response.status_coed, 200) diff --git a/group/views.py b/group/views.py index 6a9d2d1..d75aa98 100644 --- a/group/views.py +++ b/group/views.py @@ -236,9 +236,10 @@ class JoinGroupRequestAdminAPIView(APIView, GroupAPIViewBase): join_request.status = True join_request.save() - if data["status"]: if join_group(join_request.user, join_request.group): + join_request.accepted = True + join_request.save() return success_response(u"加入成功") else: return error_response(u"加入失败,已经在本小组内") @@ -248,6 +249,7 @@ class JoinGroupRequestAdminAPIView(APIView, GroupAPIViewBase): else: return serializer_invalid_response(serializer) + @login_required def group_list_page(request, page=1): # 右侧的公告列表 @@ -283,3 +285,31 @@ def group_list_page(request, page=1): "previous_page": previous_page, "next_page": next_page, "keyword": keyword, "announcements": announcements, }) + + +@login_required +def group_page(request, group_id): + try: + group = Group.objects.get(id=group_id, visible=True) + except Group.DoesNotExist: + return error_page(request, u"小组不存在") + return render(request, "oj/group/group.html", {"group": group}) + +@login_required +def application_list_page(request, group_id): + try: + group = Group.objects.get(id=group_id, visible=True) + except Group.DoesNotExist: + return error_page(request, u"小组不存在") + applications = JoinGroupRequest.objects.filter(user=request.user, group=group) + return render(request, "oj/group/my_application_list.html", + {"group": group, "applications": applications}) + +@login_required +def application_page(request, request_id): + try: + application = JoinGroupRequest.objects.get(user=request.user, pk=request_id) + except JoinGroupRequest.DoesNotExist: + return error_page(request, u"申请不存在") + return render(request, "oj/group/my_application.html", + {"application": application}) \ No newline at end of file diff --git a/judge/Dockerfile b/judge/Dockerfile new file mode 100644 index 0000000..c2ca1b1 --- /dev/null +++ b/judge/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:14.04 +MAINTAINER virusdefender +RUN mkdir /var/install/ +WORKDIR /var/install/ +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update +RUN apt-get -y install software-properties-common python-software-properties +RUN add-apt-repository -y ppa:webupd8team/java +RUN apt-get update +RUN apt-get -y install python gcc g++ rake pkg-config git make autoconf automake libtool python-pip python2.7-mysqldb +RUN echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections +RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections +RUN apt-get install -y oracle-java7-installer +RUN apt-get -y install libseccomp-dev +RUN git clone https://github.com/quark-zju/lrun.git +RUN cd lrun && make install +RUN mkdir -p /var/judger/run/ && mkdir /var/judger/test_case/ && mkdir /var/judger/code/ +RUN chmod -R 777 /var/judger/run/ +WORKDIR /var/judger/code/ \ No newline at end of file diff --git a/judge/judger_controller/settings.py b/judge/judger_controller/settings.py index a0d3e66..aff08b1 100644 --- a/judge/judger_controller/settings.py +++ b/judge/judger_controller/settings.py @@ -1,4 +1,5 @@ # coding=utf-8 +# 这个redis 是 celery 使用的,包括存储队列信息还有部分统计信息 redis_config = { "host": "121.42.32.129", "port": 6379, @@ -6,17 +7,21 @@ redis_config = { } +# 判题的 docker 容器的配置参数 docker_config = { - "image_name": " a7673b55d263", + "image_name": "3da0e526934e", "docker_path": "docker", "shell": True } -test_case_dir = "/root/test_case/" -source_code_dir = "/root/" +# 测试用例的路径,是主机上的实际路径 +test_case_dir = "/var/mnt/source/test_case/" +# 源代码路径,也就是 manage.py 所在的实际路径 +source_code_dir = "/var/mnt/source/OnlineJudge/" +# 存储提交信息的数据库,是 celery 使用的,与 oj.settings/local_settings 等区分,那是 web 服务器访问的地址 submission_db = { "host": "127.0.0.1", "port": 3306, diff --git a/oj/daocloud_settings.py b/oj/daocloud_settings.py deleted file mode 100644 index a99e009..0000000 --- a/oj/daocloud_settings.py +++ /dev/null @@ -1,19 +0,0 @@ -# coding=utf-8 -import os - -LOG_PATH = "LOG/" - -# Database -# https://docs.djangoproject.com/en/1.8/ref/settings/#databases -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - 'CONN_MAX_AGE': 1, - } -} - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True \ No newline at end of file diff --git a/oj/local_settings.py b/oj/local_settings.py index da1a672..b923291 100644 --- a/oj/local_settings.py +++ b/oj/local_settings.py @@ -5,22 +5,23 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # 下面是需要自己修改的 -LOG_PATH = "LOG/" +LOG_PATH = "log/" # 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - 'CONN_MAX_AGE': 0.3, }, + # submission 的 name 和 engine 请勿修改,其他代码会用到 'submission': { 'NAME': 'oj_submission', 'ENGINE': 'django.db.backends.mysql', 'HOST': "121.42.32.129", - 'POST': 3306, + 'PORT': 3306, 'USER': 'root', - 'PASSWORD': 'mypwd' + 'PASSWORD': 'mypwd', + 'CONN_MAX_AGE': 0.1, } } @@ -29,5 +30,4 @@ DEBUG = True # 同理 这是 web 服务器的上传路径 TEST_CASE_DIR = os.path.join(BASE_DIR, 'test_case/') -DATABASE_ROUTERS = ['oj.db_router.DBRouter'] - +ALLOWED_HOSTS = [] diff --git a/oj/server_settings.py b/oj/server_settings.py index 9bad579..185bf6b 100644 --- a/oj/server_settings.py +++ b/oj/server_settings.py @@ -1 +1,37 @@ # coding=utf-8 +import os + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# 下面是需要自己修改的 +LOG_PATH = "/var/log/oj/" + +# 注意这是web 服务器访问的地址,判题端访问的地址不一定一样,因为可能不在一台机器上 +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': "oj", + 'CONN_MAX_AGE': 0.1, + 'HOST': '127.0.0.1', + 'PORT': 3306, + 'USER': 'root', + 'PASSWORD': 'mypwd' + }, + 'submission': { + 'NAME': 'oj_submission', + 'ENGINE': 'django.db.backends.mysql', + 'CONN_MAX_AGE': 0.1, + 'HOST': "127.0.0.1", + 'PORT': 3306, + 'USER': 'root', + 'PASSWORD': 'mypwd' + } +} + +DEBUG = True + +# 同理 这是 web 服务器的上传路径 +TEST_CASE_DIR = '/root/test_case/' + +ALLOWED_HOSTS = ['*'] diff --git a/oj/settings.py b/oj/settings.py index cf4dafc..097a4c2 100644 --- a/oj/settings.py +++ b/oj/settings.py @@ -14,15 +14,13 @@ https://docs.djangoproject.com/en/1.8/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -# todo 判断运行环境 +# 判断运行环境 ENV = os.environ.get("oj_env", "local") if ENV == "local": from .local_settings import * elif ENV == "server": from .server_settings import * -elif ENV == "daocloud": - from .daocloud_settings import * BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -33,7 +31,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'hzfp^8mbgapc&x%$#xv)0=t8s7_ilingw(q3!@h&2fty6v6fxz' -ALLOWED_HOSTS = [] + # Application definition @@ -115,10 +113,6 @@ STATIC_URL = '/static/' STATICFILES_DIRS = (os.path.join(BASE_DIR, "static/src/"),) -TEMPLATE_DIRS = ( - os.path.join(BASE_DIR, "template/src"), -) - AUTH_USER_MODEL = 'account.User' LOGGING = { @@ -170,4 +164,6 @@ LOGGING = { REST_FRAMEWORK = { 'TEST_REQUEST_DEFAULT_FORMAT': 'json' -} \ No newline at end of file +} + +DATABASE_ROUTERS = ['oj.db_router.DBRouter'] \ No newline at end of file diff --git a/oj/urls.py b/oj/urls.py index 08937c4..648c849 100644 --- a/oj/urls.py +++ b/oj/urls.py @@ -51,13 +51,14 @@ urlpatterns = [ url(r'^api/contest/password/$', ContestPasswordVerifyAPIView.as_view(), name="contest_password_verify_api"), url(r'^api/contest/submission/$', ContestSubmissionAPIView.as_view(), name="contest_submission_api"), url(r'^api/submission/$', SubmissionAPIView.as_view(), name="submission_api"), + url(r'^api/group_join/$', JoinGroupAPIView.as_view(), name="group_join_api"), url(r'^api/admin/announcement/$', AnnouncementAdminAPIView.as_view(), name="announcement_admin_api"), url(r'^api/admin/contest/$', ContestAdminAPIView.as_view(), name="contest_admin_api"), url(r'^api/admin/user/$', UserAdminAPIView.as_view(), name="user_admin_api"), url(r'^api/admin/group/$', GroupAdminAPIView.as_view(), name="group_admin_api"), url(r'^api/admin/group_member/$', GroupMemberAdminAPIView.as_view(), name="group_member_admin_api"), - url(r'^api/admin/group_join/$', JoinGroupAPIView.as_view(), name="group_join_admin_api"), + url(r'^api/admin/problem/$', ProblemAdminAPIView.as_view(), name="problem_admin_api"), url(r'^api/admin/contest_problem/$', ContestProblemAdminAPIView.as_view(), name="contest_problem_admin_api"), url(r'^api/admin/test_case_upload/$', TestCaseUploadAPIView.as_view(), name="test_case_upload_api"), @@ -88,7 +89,6 @@ urlpatterns = [ url(r'^contest/(?P\d+)/$', "contest.views.contest_page", name="contest_page"), - url(r'^problem/(?P\d+)/$', "problem.views.problem_page", name="problem_page"), url(r'^problem/(?P\d+)/$', "problem.views.problem_page", name="problem_page"), url(r'^problems/$', "problem.views.problem_list_page", name="problem_list_page"), url(r'^problems/(?P\d+)/$', "problem.views.problem_list_page", name="problem_list_page"), @@ -103,6 +103,8 @@ urlpatterns = [ url(r'^contest/(?P\d+)/rank/$', "contest.views.contest_rank_page", name="contest_rank_page"), url(r'^groups/$', "group.views.group_list_page", name="group_list_page"), - url(r'^groups/(?P\d+)/$', "group.views.group_list_page", name="group_list_page") - + url(r'^groups/(?P\d+)/$', "group.views.group_list_page", name="group_list_page"), + url(r'^group/(?P\d+)/$', "group.views.group_page", name="group_page"), + url(r'^group/(?P\d+)/applications/$', "group.views.application_list_page", name="group_application_page"), + url(r'^group/application/(?P\d+)/$', "group.views.application_page", name="group_application") ] diff --git a/problem/serizalizers.py b/problem/serizalizers.py index 1fb61cc..f9c5caa 100644 --- a/problem/serizalizers.py +++ b/problem/serizalizers.py @@ -26,8 +26,8 @@ class CreateProblemSerializer(serializers.Serializer): samples = ProblemSampleSerializer() test_case_id = serializers.CharField(max_length=40) source = serializers.CharField(max_length=30, required=False, default=None) - time_limit = serializers.IntegerField() - memory_limit = serializers.IntegerField() + time_limit = serializers.IntegerField(min_value=1) + memory_limit = serializers.IntegerField(min_value=1) difficulty = serializers.IntegerField() tags = serializers.ListField(child=serializers.CharField(max_length=10)) hint = serializers.CharField(max_length=3000, allow_blank=True) @@ -61,8 +61,8 @@ class EditProblemSerializer(serializers.Serializer): output_description = serializers.CharField(max_length=10000) test_case_id = serializers.CharField(max_length=40) source = serializers.CharField(max_length=30) - time_limit = serializers.IntegerField() - memory_limit = serializers.IntegerField() + time_limit = serializers.IntegerField(min_value=1) + memory_limit = serializers.IntegerField(min_value=1) difficulty = serializers.IntegerField() tags = serializers.ListField(child=serializers.CharField(max_length=20)) samples = ProblemSampleSerializer() diff --git a/requirements.txt b/requirements.txt index 9ad8f3f..3a706b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ django-rest-swagger celery gunicorn coverage -django-extensions \ No newline at end of file +django-extensions +supervisor \ No newline at end of file diff --git a/static/src/js/app/admin/contest/contestList.js b/static/src/js/app/admin/contest/contestList.js index 4135fce..c920cd6 100644 --- a/static/src/js/app/admin/contest/contestList.js +++ b/static/src/js/app/admin/contest/contestList.js @@ -149,16 +149,8 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker", vm.editingContestId = contestId; vm.editTitle = vm.contestList[contestId-1].title; vm.editPassword = vm.contestList[contestId-1].password; - //var startTime = new Date(), endTime = new Date(); - //startTime.setFullYear(parseInt(vm.contestList[contestId-1].start_time.substring(0,4))) - //startTime.setMonth(parseInt(vm.contestList[contestId-1].start_time.substring(5,7))) - //startTime.setDate(parseInt(vm.contestList[contestId-1].start_time.substring(8,10))) - //startTime.setHours(parseInt(vm.contestList[contestId-1].start_time.substring(11,13))) - //startTime.setMinutes(parseInt(vm.contestList[contestId-1].start_time.substring(14,16))) - //startTime = new Date(startTime + 8 * 60 * 60 * 1000) - - vm.editStartTime = add8Hours(vm.contestList[contestId-1].start_time); - vm.editEndTime = add8Hours(vm.contestList[contestId-1].end_time);//.substring(0,16).replace("T"," "); + vm.editStartTime = vm.contestList[contestId-1].start_time.substring(0,16).replace("T"," "); + vm.editEndTime = vm.contestList[contestId-1].end_time.substring(0,16).replace("T"," "); vm.editMode = vm.contestList[contestId-1].mode; vm.editVisible = vm.contestList[contestId-1].visible; if (vm.contestList[contestId-1].contest_type == 0) { //contest type == 0, contest in group @@ -300,39 +292,6 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker", }); } - function add8Hours(UtcString) { - console.log(UtcString); - var M = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - /*time.setFullYear(parseInt(UtcString.substring(0,4))) - time.setMonth(parseInt(UtcString.substring(5,7))) - time.setDate(parseInt(UtcString.substring(8,10))) - time.setHours(parseInt(UtcString.substring(11,13))) - time.setMinutes(parseInt(UtcString.substring(14,16))) - time = new Date(time + 8 * 60 * 60 * 1000)*/ - var year =UtcString.substring(0,4); - var month =UtcString.substring(5,7); - var day =UtcString.substring(8,10); - var hour =parseInt(UtcString.substring(11,13)) + 8; - var minute = UtcString.substring(14,16); - if (hour > 23) { - hour -= 24; day = parseInt(day)+1; month = parseInt(month); - if (month == 2) if (!(year%400)||(!(year%4)&&year%100)) M[2] = 29; - if (day > M[month]) { - day = 1; - month = parseInt(month)+1; - if (month > 12) { - year=parseInt(year)+1; month = 1; - } - } - month = month.toString(); - day = day.toString(); - if (month.length==1) month = "0"+month; - if (day.length==1) day = "0"+day; - } - hour = hour.toString(); - if (hour.length==1) hour="0"+hour; - return year+"-"+month+"-"+day+" "+hour+":"+minute; - } // Get group list $.ajax({ // Get current user type url: "/api/user/", diff --git a/static/src/js/app/admin/problem/addProblem.js b/static/src/js/app/admin/problem/addProblem.js index d34cd9a..c6e49ca 100644 --- a/static/src/js/app/admin/problem/addProblem.js +++ b/static/src/js/app/admin/problem/addProblem.js @@ -13,10 +13,6 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE bsAlert("题目描述不能为空!"); return false; } - if (vm.timeLimit < 1000 || vm.timeLimit > 5000) { - bsAlert("保证时间限制是一个1000-5000的合法整数"); - return false; - } if (vm.samples.length == 0) { bsAlert("请至少添加一组样例!"); return false; diff --git a/static/src/js/app/oj/group/group.js b/static/src/js/app/oj/group/group.js new file mode 100644 index 0000000..918b661 --- /dev/null +++ b/static/src/js/app/oj/group/group.js @@ -0,0 +1,25 @@ +require(["jquery", "csrfToken", "bsAlert"], function ($, csrfTokenHeader, bsAlert) { + $("#sendApplication").click(function (){ + var message = $("#applyMessage").val(); + console.log(message); + var groupId = window.location.pathname.split("/")[2]; + console.log(groupId); + data = {group_id: groupId,message:message} + $.ajax({ + url: "/api/group_join/", + method: "post", + dataType: "json", + beforeSend: csrfTokenHeader, + data: JSON.stringify(data), + contentType: "application/json", + success: function (data) { + if (data.code) { + bsAlert(data.data); + } + else { + bsAlert("申请已提交!"); + } + } + }) + }) +}) diff --git a/template/src/oj/group/group.html b/template/src/oj/group/group.html new file mode 100644 index 0000000..1686a4c --- /dev/null +++ b/template/src/oj/group/group.html @@ -0,0 +1,40 @@ +{% extends 'oj_base.html' %} + +{% block body %} +
+ +

{{ group.name }}

+ +

发布时间 : {{ group.create_time }}   + 创建者 : {{ group.admin }} +

+ +
+
+ + +

{{ group.description|safe }}

+
+
+
+
+ {% if group.join_group_setting %} +
+ + + +
+ {% endif %} +
+ +
+
+
+{% endblock %} +{% block js_block %} + +{% endblock %} \ No newline at end of file diff --git a/template/src/oj/group/my_application.html b/template/src/oj/group/my_application.html new file mode 100644 index 0000000..71ba5cb --- /dev/null +++ b/template/src/oj/group/my_application.html @@ -0,0 +1,26 @@ +{% extends 'oj_base.html' %} + +{% block body %} + +
+ + +

{{ application.message|safe }}

+ + {% if application.status %} + {% if application.accepted %} +

管理员接受了你的请求

+ {% else %} +

管理员拒绝了你的请求

+ {% endif %} + {% else %} +

待审核

+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/template/src/oj/group/my_application_list.html b/template/src/oj/group/my_application_list.html new file mode 100644 index 0000000..f2b276c --- /dev/null +++ b/template/src/oj/group/my_application_list.html @@ -0,0 +1,44 @@ +{% extends 'oj_base.html' %} + +{% block body %} + +
+ + {% if applications %} + + + + + + + + + + {% for item in applications %} + + + + {% if item.status %} + {% if item.accepted %} + + {% else %} + + {% endif %} + {% else %} + + {% endif %} + + {% endfor %} + + +
#提交时间结果
{{ forloop.counter }}{{ item.create_time }}通过拒绝未处理
+ {% else %} +

你还没有申请该小组

+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/template/src/oj/index.html b/template/src/oj/index.html index af54f1d..181fa31 100644 --- a/template/src/oj/index.html +++ b/template/src/oj/index.html @@ -8,71 +8,65 @@ @@ -103,20 +97,7 @@ 提交   比赛   小组   - 关于   - + 关于 @@ -124,9 +105,9 @@
-

青岛大学在线评测平台

+

青岛大学 Online Judge

-

全新面貌,新的开始~

+

新的面貌,新的开始~

↓继续滚动~
@@ -156,7 +137,7 @@
-

自由举办小组赛

+

自由举办小组赛(10月上线)

内部比赛,日常作业,期末考试,通通搞定

diff --git a/template/src/oj/problem/problem.html b/template/src/oj/problem/problem.html index 2efd86a..b82fc01 100644 --- a/template/src/oj/problem/problem.html +++ b/template/src/oj/problem/problem.html @@ -23,7 +23,7 @@
-

{{ problem.output_description }}k

+

{{ problem.output_description }}

{% for item in samples %}
diff --git a/template/src/oj/submission/my_submissions_list.html b/template/src/oj/submission/my_submissions_list.html index c1204be..1f91ce9 100644 --- a/template/src/oj/submission/my_submissions_list.html +++ b/template/src/oj/submission/my_submissions_list.html @@ -46,7 +46,7 @@ {% for item in submissions %} - + {{ forloop.counter |add:start_id }} {{ item.create_time }} diff --git a/template/src/oj_base.html b/template/src/oj_base.html index f39fea0..ba001e1 100644 --- a/template/src/oj_base.html +++ b/template/src/oj_base.html @@ -56,7 +56,7 @@ {{ request.user.username }}