mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 16:12:13 +00:00
创建新工程 添加了一些通用代码和数据库模型
This commit is contained in:
commit
00052d8e9b
58
.gitignore
vendored
Normal file
58
.gitignore
vendored
Normal file
@ -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/
|
0
account/__init__.py
Normal file
0
account/__init__.py
Normal file
3
account/admin.py
Normal file
3
account/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
0
account/migrations/__init__.py
Normal file
0
account/migrations/__init__.py
Normal file
15
account/models.py
Normal file
15
account/models.py
Normal file
@ -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"
|
3
account/tests.py
Normal file
3
account/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
1
account/views.py
Normal file
1
account/views.py
Normal file
@ -0,0 +1 @@
|
||||
from django.shortcuts import render
|
0
admin/__init__.py
Normal file
0
admin/__init__.py
Normal file
3
admin/admin.py
Normal file
3
admin/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
0
admin/migrations/__init__.py
Normal file
0
admin/migrations/__init__.py
Normal file
3
admin/models.py
Normal file
3
admin/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
3
admin/tests.py
Normal file
3
admin/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
admin/views.py
Normal file
3
admin/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
0
contest/__init__.py
Normal file
0
contest/__init__.py
Normal file
3
contest/admin.py
Normal file
3
contest/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
0
contest/migrations/__init__.py
Normal file
0
contest/migrations/__init__.py
Normal file
8
contest/models.py
Normal file
8
contest/models.py
Normal file
@ -0,0 +1,8 @@
|
||||
# coding=utf-8
|
||||
from django.db import models
|
||||
|
||||
from problem.models import AbstractProblem
|
||||
|
||||
|
||||
class ContestProblem(AbstractProblem):
|
||||
pass
|
3
contest/tests.py
Normal file
3
contest/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
contest/views.py
Normal file
3
contest/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
0
judge/__init__.py
Normal file
0
judge/__init__.py
Normal file
3
judge/admin.py
Normal file
3
judge/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
0
judge/migrations/__init__.py
Normal file
0
judge/migrations/__init__.py
Normal file
3
judge/models.py
Normal file
3
judge/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
3
judge/tests.py
Normal file
3
judge/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
judge/views.py
Normal file
3
judge/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
10
manage.py
Executable file
10
manage.py
Executable file
@ -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)
|
0
problem/__init__.py
Normal file
0
problem/__init__.py
Normal file
3
problem/admin.py
Normal file
3
problem/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
0
problem/migrations/__init__.py
Normal file
0
problem/migrations/__init__.py
Normal file
19
problem/models.py
Normal file
19
problem/models.py
Normal file
@ -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)
|
3
problem/tests.py
Normal file
3
problem/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
problem/views.py
Normal file
3
problem/views.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
0
qduoj/__init__.py
Normal file
0
qduoj/__init__.py
Normal file
2
qduoj/local_settings.py
Normal file
2
qduoj/local_settings.py
Normal file
@ -0,0 +1,2 @@
|
||||
# coding=utf-8
|
||||
LOG_PATH = "LOG/"
|
1
qduoj/server_settings.py
Normal file
1
qduoj/server_settings.py
Normal file
@ -0,0 +1 @@
|
||||
# coding=utf-8
|
154
qduoj/settings.py
Normal file
154
qduoj/settings.py
Normal file
@ -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,
|
||||
}
|
||||
},
|
||||
}
|
12
qduoj/urls.py
Normal file
12
qduoj/urls.py
Normal file
@ -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)),
|
||||
]
|
16
qduoj/wsgi.py
Normal file
16
qduoj/wsgi.py
Normal file
@ -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()
|
6
requirements.txt
Normal file
6
requirements.txt
Normal file
@ -0,0 +1,6 @@
|
||||
django
|
||||
MySQL-python
|
||||
redis
|
||||
django-redis-sessions
|
||||
djangorestframework
|
||||
celery
|
1
utils/__init__.py
Normal file
1
utils/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# coding=utf-8
|
1
utils/shortcuts.py
Normal file
1
utils/shortcuts.py
Normal file
@ -0,0 +1 @@
|
||||
# coding=utf-8
|
Loading…
Reference in New Issue
Block a user