From 00052d8e9ba380875955232252652effe2da1279 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Fri, 26 Jun 2015 15:59:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=96=B0=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=80=E4=BA=9B=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81=E5=92=8C=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 58 +++++++++++++ README.md | 0 account/__init__.py | 0 account/admin.py | 3 + account/migrations/__init__.py | 0 account/models.py | 15 ++++ account/tests.py | 3 + account/views.py | 1 + admin/__init__.py | 0 admin/admin.py | 3 + admin/migrations/__init__.py | 0 admin/models.py | 3 + admin/tests.py | 3 + admin/views.py | 3 + contest/__init__.py | 0 contest/admin.py | 3 + contest/migrations/__init__.py | 0 contest/models.py | 8 ++ contest/tests.py | 3 + contest/views.py | 3 + judge/__init__.py | 0 judge/admin.py | 3 + judge/migrations/__init__.py | 0 judge/models.py | 3 + judge/tests.py | 3 + judge/views.py | 3 + manage.py | 10 +++ problem/__init__.py | 0 problem/admin.py | 3 + problem/migrations/__init__.py | 0 problem/models.py | 19 ++++ problem/tests.py | 3 + problem/views.py | 3 + qduoj/__init__.py | 0 qduoj/local_settings.py | 2 + qduoj/server_settings.py | 1 + qduoj/settings.py | 154 +++++++++++++++++++++++++++++++++ qduoj/urls.py | 12 +++ qduoj/wsgi.py | 16 ++++ requirements.txt | 6 ++ utils/__init__.py | 1 + utils/shortcuts.py | 1 + 42 files changed, 352 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 account/__init__.py create mode 100644 account/admin.py create mode 100644 account/migrations/__init__.py create mode 100644 account/models.py create mode 100644 account/tests.py create mode 100644 account/views.py create mode 100644 admin/__init__.py create mode 100644 admin/admin.py create mode 100644 admin/migrations/__init__.py create mode 100644 admin/models.py create mode 100644 admin/tests.py create mode 100644 admin/views.py create mode 100644 contest/__init__.py create mode 100644 contest/admin.py create mode 100644 contest/migrations/__init__.py create mode 100644 contest/models.py create mode 100644 contest/tests.py create mode 100644 contest/views.py create mode 100644 judge/__init__.py create mode 100644 judge/admin.py create mode 100644 judge/migrations/__init__.py create mode 100644 judge/models.py create mode 100644 judge/tests.py create mode 100644 judge/views.py create mode 100755 manage.py create mode 100644 problem/__init__.py create mode 100644 problem/admin.py create mode 100644 problem/migrations/__init__.py create mode 100644 problem/models.py create mode 100644 problem/tests.py create mode 100644 problem/views.py create mode 100644 qduoj/__init__.py create mode 100644 qduoj/local_settings.py create mode 100644 qduoj/server_settings.py create mode 100644 qduoj/settings.py create mode 100644 qduoj/urls.py create mode 100644 qduoj/wsgi.py create mode 100644 requirements.txt create mode 100644 utils/__init__.py create mode 100644 utils/shortcuts.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1d6c7243 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +# C extensions +*.so +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml +# Translations +*.mo +# Mr Developer +.mr.developer.cfg +.project +.pydevproject +# Rope +.ropeproject +.idea/ +# Django stuff: +*.log +*.pot +# Sphinx documentation +docs/_build/ +# Back up file +*~ +#db file +db.db +#vim cache +*swp +*swo +#redis dump +*.rdb +#*.out +db.sqlite3 +.DS_Store +log/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..e69de29b diff --git a/account/__init__.py b/account/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/account/admin.py b/account/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/account/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/account/migrations/__init__.py b/account/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/account/models.py b/account/models.py new file mode 100644 index 00000000..3b4bef7a --- /dev/null +++ b/account/models.py @@ -0,0 +1,15 @@ +# coding=utf-8 +from django.db import models +from django.contrib.auth.models import AbstractBaseUser + + +class AdminGroup(models.Model): + pass + + +class User(AbstractBaseUser): + username = models.CharField(max_length=30, unique=True) + admin_group = models.ForeignKey(AdminGroup, null=True, on_delete=models.SET_NULL) + + class Meta: + db_table = "user" diff --git a/account/tests.py b/account/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/account/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/account/views.py b/account/views.py new file mode 100644 index 00000000..a9ec5d8c --- /dev/null +++ b/account/views.py @@ -0,0 +1 @@ +from django.shortcuts import render \ No newline at end of file diff --git a/admin/__init__.py b/admin/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/admin/admin.py b/admin/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/admin/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/admin/migrations/__init__.py b/admin/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/admin/models.py b/admin/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/admin/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/admin/tests.py b/admin/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/admin/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/admin/views.py b/admin/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/admin/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/contest/__init__.py b/contest/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contest/admin.py b/contest/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/contest/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/contest/migrations/__init__.py b/contest/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/contest/models.py b/contest/models.py new file mode 100644 index 00000000..1088232c --- /dev/null +++ b/contest/models.py @@ -0,0 +1,8 @@ +# coding=utf-8 +from django.db import models + +from problem.models import AbstractProblem + + +class ContestProblem(AbstractProblem): + pass diff --git a/contest/tests.py b/contest/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/contest/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/contest/views.py b/contest/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/contest/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/judge/__init__.py b/judge/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/judge/admin.py b/judge/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/judge/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/judge/migrations/__init__.py b/judge/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/judge/models.py b/judge/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/judge/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/judge/tests.py b/judge/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/judge/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/judge/views.py b/judge/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/judge/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/manage.py b/manage.py new file mode 100755 index 00000000..b4ba9771 --- /dev/null +++ b/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "qduoj.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/problem/__init__.py b/problem/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/problem/admin.py b/problem/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/problem/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/problem/migrations/__init__.py b/problem/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/problem/models.py b/problem/models.py new file mode 100644 index 00000000..584fc24d --- /dev/null +++ b/problem/models.py @@ -0,0 +1,19 @@ +# coding=utf-8 +from django.db import models + +from account.models import User + + +class AbstractProblem(models.Model): + + class Meta: + abstract = True + + +class Problem(AbstractProblem): + pass + + +class Solution(models.Model): + user = models.ForeignKey(User) + problem = models.ForeignKey(Problem) \ No newline at end of file diff --git a/problem/tests.py b/problem/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/problem/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/problem/views.py b/problem/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/problem/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/qduoj/__init__.py b/qduoj/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/qduoj/local_settings.py b/qduoj/local_settings.py new file mode 100644 index 00000000..5e898d36 --- /dev/null +++ b/qduoj/local_settings.py @@ -0,0 +1,2 @@ +# coding=utf-8 +LOG_PATH = "LOG/" \ No newline at end of file diff --git a/qduoj/server_settings.py b/qduoj/server_settings.py new file mode 100644 index 00000000..9bad5790 --- /dev/null +++ b/qduoj/server_settings.py @@ -0,0 +1 @@ +# coding=utf-8 diff --git a/qduoj/settings.py b/qduoj/settings.py new file mode 100644 index 00000000..cf9ab2d4 --- /dev/null +++ b/qduoj/settings.py @@ -0,0 +1,154 @@ +# coding=utf-8 +""" +Django settings for qduoj project. + +Generated by 'django-admin startproject' using Django 1.8. + +For more information on this file, see +https://docs.djangoproject.com/en/1.8/topics/settings/ + +For the full list of settings and their values, see +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 = "local" + +if ENV == "local": + from .local_settings import * +else: + from .server_settings import * + +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' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.security.SecurityMiddleware', +) + +ROOT_URLCONF = 'qduoj.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'template')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'qduoj.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.8/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'CONN_MAX_AGE': 1, + } +} + + +# Internationalization +# https://docs.djangoproject.com/en/1.8/topics/i18n/ + +LANGUAGE_CODE = 'zh-cn' + +TIME_ZONE = 'Asia/Shanghai' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.8/howto/static-files/ + +STATIC_URL = '/static/' + +STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),) + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': True, + 'formatters': { + 'standard': { + 'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] [%(module)s:%(funcName)s] [%(levelname)s]- %(message)s'} + # 日志格式 + }, + 'handlers': { + 'file_handler': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': LOG_PATH + 'info.log', + 'formatter': 'standard' + }, + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'standard' + } + }, + 'loggers': { + 'info_logger': { + 'handlers': ['file_handler', "console"], + 'level': 'DEBUG', + 'propagate': True + }, + 'django.request': { + 'handlers': ['file_handler', 'console'], + 'level': 'DEBUG', + 'propagate': True, + }, + 'django.db.backends': { + 'handlers': ['console'], + 'level': 'DEBUG', + 'propagate': True, + } + }, +} diff --git a/qduoj/urls.py b/qduoj/urls.py new file mode 100644 index 00000000..3f06f9a5 --- /dev/null +++ b/qduoj/urls.py @@ -0,0 +1,12 @@ +# coding=utf-8 +from django.conf.urls import include, url +from django.contrib import admin +from django.views.generic import TemplateView + +urlpatterns = [ + # Examples: + # url(r'^$', 'qduoj.views.home', name='home'), + # url(r'^blog/', include('blog.urls')), + + url(r'^admin/', include(admin.site.urls)), +] diff --git a/qduoj/wsgi.py b/qduoj/wsgi.py new file mode 100644 index 00000000..5fe94cc1 --- /dev/null +++ b/qduoj/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for qduoj project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "qduoj.settings") + +application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..21a0a191 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +django +MySQL-python +redis +django-redis-sessions +djangorestframework +celery diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 00000000..9bad5790 --- /dev/null +++ b/utils/__init__.py @@ -0,0 +1 @@ +# coding=utf-8 diff --git a/utils/shortcuts.py b/utils/shortcuts.py new file mode 100644 index 00000000..9bad5790 --- /dev/null +++ b/utils/shortcuts.py @@ -0,0 +1 @@ +# coding=utf-8