mail 拆分模块

增加 js 的压缩配置

修改设置,增加备案号

Squash from 3dd19cf to bfc4123 by virusdefender
This commit is contained in:
virusdefender 2015-12-07 19:14:43 +08:00
parent 6292592b98
commit 492e7446b1
8 changed files with 95 additions and 89 deletions

View File

@ -14,7 +14,7 @@ from rest_framework.response import Response
from utils.shortcuts import (serializer_invalid_response, error_response,
success_response, error_page, paginate, rand_str)
from utils.captcha import Captcha
from mail.tasks import send_email
from utils.mail import send_email
from .decorators import login_required
from .models import User, UserProfile

View File

@ -1 +0,0 @@
# coding=utf-8

View File

@ -1 +0,0 @@
# coding=utf-8

View File

@ -1,19 +0,0 @@
# coding=utf-8
import os
from envelopes import Envelope
SMTP_CONFIG = {"smtp_server": "smtp.mxhichina.com",
"email": "noreply@qduoj.com",
"password": os.environ.get("smtp_password", "111111"),
"tls": False}
def send_email(from_name, to_email, to_name, subject, content):
envelope = Envelope(from_addr=(SMTP_CONFIG["email"], from_name),
to_addr=(to_email, to_name),
subject=subject,
html_body=content)
envelope.send(SMTP_CONFIG["smtp_server"],
login=SMTP_CONFIG["email"],
password=SMTP_CONFIG["password"],
tls=SMTP_CONFIG["tls"])

View File

@ -50,7 +50,6 @@ INSTALLED_APPS = (
'submission',
'mq',
'contest',
'mail',
'django_extensions',
'rest_framework',
@ -102,7 +101,7 @@ LANGUAGE_CODE = 'zh-cn'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_I18N = False
USE_L10N = True
@ -118,7 +117,6 @@ AUTH_USER_MODEL = 'account.User'
LOG_PATH = "log/"
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
@ -184,5 +182,10 @@ TEST_CASE_DIR = os.path.join(BASE_DIR, 'test_case/')
IMAGE_UPLOAD_DIR = os.path.join(BASE_DIR, 'upload/')
WEBSITE_INFO = {"website_name": "qduoj",
"website_footer": u"青岛大学信息工程学院 创新实验室",
"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}

View File

@ -57,25 +57,28 @@
problem_2_pack: "app/oj/problem/problem",
submissionList_3_pack: "app/admin/problem/submissionList",
contestCountdown_4_pack: "app/oj/contest/contestCountdown",
addProblem_5_pack: "app/admin/problem/addProblem",
problem_6_pack: "app/admin/problem/problem",
contestList_7_pack: "app/admin/contest/contestList",
admin_8_pack: "app/admin/admin",
login_9_pack: "app/oj/account/login",
addContest_10_pack: "app/admin/contest/addContest",
contestPassword_11_pack: "app/oj/contest/contestPassword",
changePassword_12_pack: "app/oj/account/changePassword",
monitor_13_pack: "app/admin/monitor/monitor",
editProblem_14_pack: "app/admin/contest/editProblem",
joinGroupRequestList_15_pack: "app/admin/group/joinGroupRequestList",
group_16_pack: "app/oj/group/group",
contestProblemList_17_pack: "app/admin/contest/contestProblemList",
editProblem_18_pack: "app/admin/problem/editProblem",
register_19_pack: "app/oj/account/register",
groupDetail_20_pack: "app/admin/group/groupDetail",
editContest_21_pack: "app/admin/contest/editContest",
group_22_pack: "app/admin/group/group",
settings_23_pack: "app/oj/account/settings"
avatar_5_pack: "app/oj/account/avatar",
addProblem_6_pack: "app/admin/problem/addProblem",
problem_7_pack: "app/admin/problem/problem",
contestList_8_pack: "app/admin/contest/contestList",
admin_9_pack: "app/admin/admin",
login_10_pack: "app/oj/account/login",
applyResetPassword_11_pack: "app/oj/account/applyResetPassword",
addContest_12_pack: "app/admin/contest/addContest",
contestPassword_13_pack: "app/oj/contest/contestPassword",
changePassword_14_pack: "app/oj/account/changePassword",
monitor_15_pack: "app/admin/monitor/monitor",
editProblem_16_pack: "app/admin/contest/editProblem",
joinGroupRequestList_17_pack: "app/admin/group/joinGroupRequestList",
group_18_pack: "app/oj/group/group",
contestProblemList_19_pack: "app/admin/contest/contestProblemList",
editProblem_20_pack: "app/admin/problem/editProblem",
register_21_pack: "app/oj/account/register",
groupDetail_22_pack: "app/admin/group/groupDetail",
editContest_23_pack: "app/admin/contest/editContest",
resetPassword_24_pack: "app/oj/account/resetPassword",
group_25_pack: "app/admin/group/group",
settings_26_pack: "app/oj/account/settings"
},
shim: {
avalon: {
@ -86,12 +89,6 @@
appDir: "../",
dir: "../../release/",
modules: [
{
name: "bootstrap",
},
{
name: "codeMirror"
},
{
name: "announcement_0_pack"
},
@ -108,62 +105,71 @@
name: "contestCountdown_4_pack"
},
{
name: "addProblem_5_pack"
name: "avatar_5_pack"
},
{
name: "problem_6_pack"
name: "addProblem_6_pack"
},
{
name: "contestList_7_pack"
name: "problem_7_pack"
},
{
name: "admin_8_pack"
name: "contestList_8_pack"
},
{
name: "login_9_pack"
name: "admin_9_pack"
},
{
name: "addContest_10_pack"
name: "login_10_pack"
},
{
name: "contestPassword_11_pack"
name: "applyResetPassword_11_pack"
},
{
name: "changePassword_12_pack"
name: "addContest_12_pack"
},
{
name: "monitor_13_pack"
name: "contestPassword_13_pack"
},
{
name: "editProblem_14_pack"
name: "changePassword_14_pack"
},
{
name: "joinGroupRequestList_15_pack"
name: "monitor_15_pack"
},
{
name: "group_16_pack"
name: "editProblem_16_pack"
},
{
name: "contestProblemList_17_pack"
name: "joinGroupRequestList_17_pack"
},
{
name: "editProblem_18_pack"
name: "group_18_pack"
},
{
name: "register_19_pack"
name: "contestProblemList_19_pack"
},
{
name: "groupDetail_20_pack"
name: "editProblem_20_pack"
},
{
name: "editContest_21_pack"
name: "register_21_pack"
},
{
name: "group_22_pack"
name: "groupDetail_22_pack"
},
{
name: "settings_23_pack"
name: "editContest_23_pack"
},
{
name: "resetPassword_24_pack"
},
{
name: "group_25_pack"
},
{
name: "settings_26_pack"
}
],
optimizeCss: "standard",
})

View File

@ -59,25 +59,28 @@ var require = {
problem_2_pack: "app/oj/problem/problem",
submissionList_3_pack: "app/admin/problem/submissionList",
contestCountdown_4_pack: "app/oj/contest/contestCountdown",
addProblem_5_pack: "app/admin/problem/addProblem",
problem_6_pack: "app/admin/problem/problem",
contestList_7_pack: "app/admin/contest/contestList",
admin_8_pack: "app/admin/admin",
login_9_pack: "app/oj/account/login",
addContest_10_pack: "app/admin/contest/addContest",
contestPassword_11_pack: "app/oj/contest/contestPassword",
changePassword_12_pack: "app/oj/account/changePassword",
monitor_13_pack: "app/admin/monitor/monitor",
editProblem_14_pack: "app/admin/contest/editProblem",
joinGroupRequestList_15_pack: "app/admin/group/joinGroupRequestList",
group_16_pack: "app/oj/group/group",
contestProblemList_17_pack: "app/admin/contest/contestProblemList",
editProblem_18_pack: "app/admin/problem/editProblem",
register_19_pack: "app/oj/account/register",
groupDetail_20_pack: "app/admin/group/groupDetail",
editContest_21_pack: "app/admin/contest/editContest",
group_22_pack: "app/admin/group/group",
settings_23_pack: "app/oj/account/settings"
avatar_5_pack: "app/oj/account/avatar",
addProblem_6_pack: "app/admin/problem/addProblem",
problem_7_pack: "app/admin/problem/problem",
contestList_8_pack: "app/admin/contest/contestList",
admin_9_pack: "app/admin/admin",
login_10_pack: "app/oj/account/login",
applyResetPassword_11_pack: "app/oj/account/applyResetPassword",
addContest_12_pack: "app/admin/contest/addContest",
contestPassword_13_pack: "app/oj/contest/contestPassword",
changePassword_14_pack: "app/oj/account/changePassword",
monitor_15_pack: "app/admin/monitor/monitor",
editProblem_16_pack: "app/admin/contest/editProblem",
joinGroupRequestList_17_pack: "app/admin/group/joinGroupRequestList",
group_18_pack: "app/oj/group/group",
contestProblemList_19_pack: "app/admin/contest/contestProblemList",
editProblem_20_pack: "app/admin/problem/editProblem",
register_21_pack: "app/oj/account/register",
groupDetail_22_pack: "app/admin/group/groupDetail",
editContest_23_pack: "app/admin/contest/editContest",
resetPassword_24_pack: "app/oj/account/resetPassword",
group_25_pack: "app/admin/group/group",
settings_26_pack: "app/oj/account/settings",
},
shim: {
avalon: {

15
utils/mail.py Normal file
View File

@ -0,0 +1,15 @@
# coding=utf-8
from envelopes import Envelope
from django.conf import settings
def send_email(from_name, to_email, to_name, subject, content):
envelope = Envelope(from_addr=(settings.SMTP_CONFIG["email"], from_name),
to_addr=(to_email, to_name),
subject=subject,
html_body=content)
envelope.send(settings.SMTP_CONFIG["smtp_server"],
login=settings.SMTP_CONFIG["email"],
password=settings.SMTP_CONFIG["password"],
tls=settings.SMTP_CONFIG["tls"])