Merge branch 'dev' into hohoTT-dev

This commit is contained in:
hohoTT 2015-09-09 19:12:31 +08:00
commit fddd1d866e
10 changed files with 212 additions and 3 deletions

View File

@ -106,5 +106,8 @@ urlpatterns = [
url(r'^groups/(?P<page>\d+)/$', "group.views.group_list_page", name="group_list_page"),
url(r'^group/(?P<group_id>\d+)/$', "group.views.group_page", name="group_page"),
url(r'^group/(?P<group_id>\d+)/applications/$', "group.views.application_list_page", name="group_application_page"),
url(r'^group/application/(?P<request_id>\d+)/$', "group.views.application_page", name="group_application")
url(r'^group/application/(?P<request_id>\d+)/$', "group.views.application_page", name="group_application"),
url(r'^about/$', TemplateView.as_view(template_name="utils/about.html"), name="about_page"),
url(r'^help/$', TemplateView.as_view(template_name="utils/help.html"), name="help_page"),
]

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('submission', '0005_submission_contest_id'),
]
operations = [
migrations.AddField(
model_name='submission',
name='shared',
field=models.BooleanField(default=False),
),
]

View File

@ -19,6 +19,8 @@ class Submission(models.Model):
accepted_answer_time = models.IntegerField(blank=True, null=True)
# 这个字段只有在题目是accepted 的时候才会用到,比赛题目的提交可能还会有得分等信息,存储在这里面
accepted_answer_info = models.TextField(blank=True, null=True)
# 是否可以分享
shared = models.BooleanField(default=False)
class Meta:
db_table = "submission"

View File

@ -97,7 +97,7 @@
<a href="/submissions/">提交</a>&nbsp;&nbsp;
<a href="/contests/">比赛</a>&nbsp;&nbsp;
<a href="/groups/">小组</a>&nbsp;&nbsp;
<a href="#">关于</a>
<a href="/about/">关于</a>
</div>

View File

@ -46,7 +46,7 @@
<li><a href="/submissions/">提交</a></li>
<li><a href="/contests/">比赛</a></li>
<li><a href="/groups/">小组</a></li>
<li><a href="#">关于</a></li>
<li><a href="/about/">关于</a></li>
</ul>
{% if request.user.is_authenticated %}
<ul class="nav navbar-nav navbar-right">

View File

@ -0,0 +1,73 @@
{% extends "oj_base.html" %}
{% block body %}
<div class="container main">
<ul class="nav nav-tabs nav-tabs-google">
<li role="presentation">
<a href="/help/">帮助</a>
</li>
<li role="presentation" class="active">
<a href="/about/">关于</a>
</li>
</ul>
<div>
<h2 class="text-center">ACM 简介</h2>
<p>
ACM国际大学生程序设计竞赛英语ACM International Collegiate Programming Contest,
ICPC是由美国电脑协会ACM主办的一项旨在展示大学生创新能力、团队精神和在压力下编写程序、分析和解决问题能力的年度竞赛。
经过30多年的发展ACM国际大学生程序设计竞赛已经发展成为最具影响力的大学生计算机竞赛。赛事目前由IBM公司赞助。
</p>
<p>
青岛大学 ACM 队是一支优秀的队伍,一支充满活力与激情的队伍,它满载着光辉与荣誉。在过去的几年里,集训队的队员曾代表我校多次
参加竞赛,获得了佳绩。
</p>
<p>
ACM 队会在每月举行一次 ACM 月赛,该比赛是 ACM 选拨队员的重要评据。ACM 队用比赛来保证队伍的活力,以比拼来加强队伍的素质,
正是如此ACM 队的队员在程序设计方面始几乎终代表着全院的最高水平。
</p>
<p>
如果你有意加入这支优秀的队伍,就用你的行动来证明你的优秀吧,月赛将是你展示自我的舞台。
</p>
<h2 class="text-center">开源</h2>
<p>
<a href="#" target="_blank">代码</a> <a href="#" target="_blank">文档</a>
</p>
<h2 class="text-center">开发人员</h2>
<table class="table table-bordered">
<tbody>
<tr>
<th>指导老师</th>
<th>李建波</th>
</tr>
<tr>
<th>v1.0</th>
<th>
董延鑫
邢兆龙
</th>
</tr>
<tr>
<th>v2.0</th>
<th>
董延鑫
杨玉飞
徐可飞
王波
周鲁晓
</th>
</tr>
<tr>
<th>v3.0</th>
<th>。。。</th>
</tr>
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

BIN
utils/captcha/Menlo.ttc Normal file

Binary file not shown.

112
utils/captcha/__init__.py Normal file
View File

@ -0,0 +1,112 @@
# coding:utf-8
"""
Copyright 2013 TY<tianyu0915@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import time
import random
import StringIO
import logging
from django.http import HttpResponse
from PIL import Image, ImageDraw, ImageFont
class Captcha(object):
def __init__(self, request):
"""
初始化,设置各种属性
"""
self.django_request = request
self.session_key = '_django_captcha_key'
self.captcha_expires_time = '_django_captcha_expires_time'
# 验证码图片尺寸
self.img_width = 90
self.img_height = 30
def _get_font_size(self, code):
"""
将图片高度的80%作为字体大小
"""
s1 = int(self.img_height * 0.8)
s2 = int(self.img_width / len(code))
return int(min((s1, s2)) + max((s1, s2)) * 0.05)
def _set_answer(self, answer):
"""
设置答案和过期时间
"""
self.django_request.session[self.session_key] = str(answer)
self.django_request.session[self.captcha_expires_time] = time.time() + 60
def _make_code(self):
"""
生成随机数或随机字符串
"""
string = random.sample('abcdefghkmnpqrstuvwxyzABCDEFGHGKMNOPQRSTUVWXYZ23456789', 4)
self._set_answer("".join(string))
return string
def display(self):
"""
生成验证码图片
"""
background = (random.randrange(200, 255), random.randrange(200, 255), random.randrange(200, 255))
code_color = (random.randrange(0, 50), random.randrange(0, 50), random.randrange(0, 50), 255)
font_path = os.path.join(os.path.normpath(os.path.dirname(__file__)), 'timesbi.ttf')
image = Image.new('RGB', (self.img_width, self.img_height), background)
code = self._make_code()
font_size = self._get_font_size(code)
draw = ImageDraw.Draw(image)
# x是第一个字母的x坐标
x = random.randrange(int(font_size * 0.3), int(font_size * 0.5))
for i in code:
# 字符y坐标
y = random.randrange(1, 7)
# 随机字符大小
font = ImageFont.truetype(font_path.replace('\\', '/'), font_size + random.randrange(-3, 7))
draw.text((x, y), i, font=font, fill=code_color)
# 随机化字符之间的距离 字符粘连可以降低识别率
x += font_size * random.randrange(6, 8) / 10
buf = StringIO.StringIO()
image.save(buf, 'gif')
self.django_request.session[self.session_key] = "".join(code)
return HttpResponse(buf.getvalue(), 'image/gif')
def check(self, code):
"""
检查用户输入的验证码是否正确
"""
_code = self.django_request.session.get(self.session_key) or ''
if not _code:
return False
expires_time = self.django_request.session.get(self.captcha_expires_time) or 0
# 注意 如果验证之后不清除之前的验证码的话 可能会造成重复验证的现象
del self.django_request.session[self.session_key]
del self.django_request.session[self.captcha_expires_time]
if _code.lower() == str(code).lower() and time.time() < expires_time:
return True
else:
return False

BIN
utils/captcha/timesbi.ttf Normal file

Binary file not shown.