Merge branch 'virusdefender-dev'

This commit is contained in:
virusdefender 2015-11-08 23:16:56 +08:00
commit 34c4d5ae5b
7 changed files with 86 additions and 226 deletions

View File

@ -17,7 +17,7 @@ from utils.captcha import Captcha
from mail.tasks import send_email
from .decorators import login_required
from .models import User
from .models import User, UserProfile
from .serializers import (UserLoginSerializer, UsernameCheckSerializer,
UserRegisterSerializer, UserChangePasswordSerializer,
EmailCheckSerializer, UserSerializer, EditUserSerializer,
@ -96,6 +96,7 @@ class UserRegisterAPIView(APIView):
email=data["email"])
user.set_password(data["password"])
user.save()
UserProfile.objects.create(user=user)
return success_response(u"注册成功!")
else:
return serializer_invalid_response(serializer)

View File

@ -26,6 +26,7 @@
// ------ admin web 组件 ----------
pager: "components/pager",
editorComponent: "components/editorComponent",
testCaseUploader: "components/testCaseUploader",
// ------ 下面写的都不要直接用,而是使用上面的封装版本 ------
//富文本编辑器simditor -> editor

View File

@ -41,153 +41,5 @@
<ms:pager $id="contestListPager" config="pager"></ms:pager>
</div>
<!--
<div ms-visible="editingContestId">
<form id="edit-contest-form">
<div class="col-md-12">
<label>比赛名称</label>
</div>
<div class="col-md-12">
<div class="form-group">
<input type="text" name="name" class="form-control" ms-duplex="editTitle"
data-error="请填写比赛名称(名称不能超过50个字)" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-12">
<label>说明</label>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea id="editor" placeholder="这里输入内容" autofocus ms-duplex="editDescription"></textarea>
<div class="help-block with-errors"></div>
<p class="error-info" ms-visible="editDescription==''">请填写比赛描述</p>
</div>
</div>
<div class="col-md-6">
<label>开始时间</label>
<div class="form-group">
<input type="text" class="form-control" name="start_time" id="contest_start_time"
ms-duplex="editStartTime" data-error="请填写比赛开始时间" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<label>结束时间</label>
<div class="form-group">
<input type="text" class="form-control" name="end_time" id="contest_end_time"
ms-duplex="editEndTime" data-error="请填写比赛结束时间" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>可见范围</label>
<span ms-if="showGlobalViewRadio">
<label>
<small><input type="radio" value="true" name="isGlobal" ms-duplex-boolean="isGlobal">全局可见
</small>
</label>
</span>
<span>
<label>
<small><input type="radio" value="false" name="isGlobal" ms-duplex-boolean="isGlobal">小组内可见
</small>
</label>
</span>
</div>
</div>
<div class="col-md-6" ms-visible="isGlobal">
<label>密码保护</label>
<input type="text" class="form-control" name="password" placeholder="留空就是公开赛" ms-duplex="editPassword">
</div>
<div class="form-group col-md-12" ms-visible="!isGlobal">
<div ms-repeat="allGroups" class="col-md-4">
<input type="checkbox" value="group_id" ms-duplex-checked="el.isSelected">&nbsp;&nbsp;{{ el.name }}
</div>
</div>
<div class="col-md-3">
<label>排名方式</label>
<div class="form-group">
<label><input type="radio" name="mode" ms-duplex-string="editMode" value="0">
<small>ACM</small>
</label>
<label><input type="radio" name="mode" ms-duplex-string="editMode" value="1">
<small>分数</small>
</label>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>是否可见</label>
<label><input type="checkbox" ms-duplex-checked="editVisible">
<small> 可见</small>
</label>
</div>
</div>
<div class="col-md-3">
<label>公开提交记录</label>
<div class="form-group">
<label class="text"><input type="checkbox" ms-duplex-checked="editShowSubmission">
<small>公开</small>
</label>
</div>
</div>
<div class="col-md-3">
<label>实时排名</label>
<div class="form-group">
<label class="text"><input type="checkbox" ms-duplex-checked="editRealTimeRank">
<small></small>
</label>
</div>
</div>
<div class="col-md-12">
<button class="btn btn-success" type="submit">保存修改</button>
</div>
</form>
</div>
<div class="col-md-12" ms-visible="editingProblemContestIndex">
<label>题目列表</label>
<a href="javascript:void(0)" class="btn btn-primary btn-sm" ms-click="addProblem()">添加题目</a>
<a href="javascript:void(0)" class="btn btn-info btn-sm" ms-click="showSubmissionPage()">查看提交</a>
<table class="table table-striped">
<tr>
<th>编号</th>
<th>题目</th>
<th ms-visible="editMode=='2'">分值</th>
<th>可见</th>
<th>创建时间</th>
<td></td>
</tr>
<tr ms-repeat="editProblemList">
<td>{{ el.sort_index }}</td>
<td>{{ el.title }}</td>
<td ms-visible="editMode=='2'">{{ el.score }}</td>
<td ms-text="el.visible?'可见':'不可见'"></td>
<td>{{ el.create_time|date("yyyy-MM-dd HH:mm:ss") }}</td>
<td>
<a href="javascript:void(0)" class="btn-sm btn-info"
ms-click="showProblemEditPage(el)">编辑</a>
<a href="javascript:void(0)" class="btn-sm btn-info"
ms-click="showSubmissionPage(el)">提交</a>
<a href="javascript:void(0)" class="btn-sm btn-info"
ms-click="addToProblemList(el)" ms-visible="admin_type=='2'">添加到前台</a>
</td>
</tr>
</table>
</div>
-->
</div>
<script src="/static/js/app/admin/contest/contestList.js"></script>

View File

@ -27,7 +27,7 @@
<td>{{ el.total_accepted_number }}/{{ el.total_submit_number }}</td>
<td>
<button class="btn-sm btn-info" ms-click="showEditProblemPage(el.id)">编辑</button>
<button class="btn-sm btn-primary" ms-if="!el.is_public && adminType == 2" ms-click="makeProblemPublic(el)">公开</button>
<button class="btn-sm btn-primary" ms-if="!el.is_public && adminType == 2 && el.visible" ms-click="makeProblemPublic(el)">公开</button>
</td>
</tr>
</table>

View File

@ -13,67 +13,66 @@
<li class="list-group-item"><a href="/change_password/">修改密码</a></li>
</ul>
</div>
<div class="col-lg-3">
<img src="https://coding.net/static/fruit_avatar/Fruit-1.png" class="img-responsive"
style="height: 200px;width: 200px;">
</div>
<div class="col-lg-6">
<form>
<div class="row">
<div class="form-group col-md-6"><label>用户名</label>
<input name="username" type="text" class="form-control"
value="{{ request.user.username }}" readonly>
<div class="col-lg-3">
<img src="{{ user.userprofile.avatar }}" class="img-responsive index-avatar">
</div>
<div class="col-lg-6">
<form>
<div class="row">
<div class="form-group col-md-6"><label>用户名</label>
<input name="username" type="text" class="form-control"
value="{{ request.user.username }}" readonly>
</div>
<div class="form-group col-md-6"><label>真实姓名</label>
<input name="real_name" type="text" class="form-control"
value="{{ request.user.real_name }}" readonly>
</div>
</div>
<div class="row">
<div class="form-group col-md-6"><label>电子邮箱</label>
<input name="email" type="email" class="form-control"
value="{{ request.user.email }}" readonly>
</div>
<div class="form-group col-md-6"><label>手机</label>
<input name="phone" type="text" class="form-control"
data-error="请填写手机号码" value="{{ request.user.phone }}">
</div>
</div>
<div class="row">
</div>
<div class="form-group col-md-6"><label>真实姓名</label>
<input name="real_name" type="text" class="form-control"
value="{{ request.user.real_name }}" readonly>
<div class="form-group col-md-6">
<label>hduoj 用户</label>
<input name=hduoj" type="text" class="form-control"
value="{{ request.user.hduoj_username }}">
</div>
</div>
<div class="row">
<div class="form-group col-md-6"><label>电子邮箱</label>
<input name="email" type="email" class="form-control"
value="{{ request.user.email }}" readonly>
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-6"><label>手机</label>
<input name="phone" type="text" class="form-control"
data-error="请填写手机号码" value="{{ request.user.phone }}">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-6">
<label>BestCoder 用户名</label>
<input name=bestcoder" type="text" class="form-control"
value="{{ request.user.bestcoder_username }}">
<div class="form-group col-md-6">
<label>hduoj 用户名</label>
<input name=hduoj" type="text" class="form-control"
value="{{ request.user.hduoj_username }}">
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-6">
<label>BestCoder 用户名</label>
<input name=bestcoder" type="text" class="form-control"
value="{{ request.user.bestcoder_username }}">
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-6">
<label>Codeforces 用户名</label>
<input name=codeforces" type="text" class="form-control"
value="{{ request.user.bestcoder_username }}">
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-12"><label>blog</label>
<input name=blog" type="url" class="form-control"
value="{{ request.user.blog }}">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-6">
<label>Codeforces 用户名</label>
<input name=codeforces" type="text" class="form-control"
value="{{ request.user.bestcoder_username }}">
<div class="form-group">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
<div class="help-block with-errors"></div>
</div>
<div class="form-group col-md-12"><label>blog</label>
<input name=blog" type="url" class="form-control"
value="{{ request.user.blog }}">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@ -19,7 +19,9 @@
{% endifequal %}
</h2>
<p id="user-mood">{{ user.userprofile.mood }}</p>
{% if user.userprofile.mood %}
<p id="user-mood">{{ user.userprofile.mood }}</p>
{% endif %}
</div>
<div class="list-group col-lg-9">
@ -61,15 +63,17 @@
{{ user.create_time }}
</p>
<div class="rows">
<!--
<div class="col-lg-4 text-center">
<strong id="user-data-number">{{ user.userprofile.rank }}</strong>
<span id="user-data-text">Rank</span>
</div>
<div class="col-lg-4 text-center">
-->
<div class="col-lg-6 text-center">
<strong id="user-data-number">{{ user.userprofile.accepted_number }}</strong>
<span id="user-data-text">AC</span>
</div>
<div class="col-lg-4 text-center">
<div class="col-lg-6 text-center">
<strong id="user-data-number">{{ user.userprofile.submissions_number }}</strong>
<span id="user-data-text">Submissions</span>
</div>

View File

@ -72,24 +72,27 @@
onchange="if(this.checked){location.href=location.href + '&auto_refresh=true'}else{location.href=location.href=location.href.replace('&auto_refresh=true', '')}">
自动刷新
<nav>
<ul class="pager">
{% if paging_info.previous_page %}
<li class="previous">
<a href="/contest/{{ contest.id }}/rank/?paging=true&page={{ paging_info.previous_page }}&page_size={{ paging_info.page_size }}{% if auto_refresh %}&auto_refresh=true{% endif %}">
<ul class="pager">
{% if paging_info.previous_page %}
<li class="previous">
<a href="/contest/{{ contest.id }}/rank/?paging=true&page={{ paging_info.previous_page }}&page_size={{ paging_info.page_size }}{% if auto_refresh %}&auto_refresh=true{% endif %}">
<span aria-hidden="true">&larr;</span> 上一页
</a></li>
{% endif %}
{% if paging_info.next_page %}
<li class="next">
<a href="/contest/{{ contest.id }}/rank/?paging=true&page={{ paging_info.next_page }}&page_size={{ paging_info.page_size }}{% if auto_refresh %}&auto_refresh=true{% endif %}">
下一页 <span aria-hidden="true">&rarr;</span>
</a></li>
{% endif %}
</ul>
</nav>
<span aria-hidden="true">&larr;</span> 上一页
</a></li>
{% endif %}
{% if paging_info.next_page %}
<li class="next">
<a href="/contest/{{ contest.id }}/rank/?paging=true&page={{ paging_info.next_page }}&page_size={{ paging_info.page_size }}{% if auto_refresh %}&auto_refresh=true{% endif %}">
下一页 <span aria-hidden="true">&rarr;</span>
</a></li>
{% endif %}
</ul>
</nav>
{% else %}
<p>还没有结果</p>
<input type="checkbox" id="auto-refresh" {% if auto_refresh %}checked{% endif %}
onchange="if(this.checked){location.href=location.href + '&auto_refresh=true'}else{location.href=location.href=location.href.replace('&auto_refresh=true', '')}">
自动刷新
{% endif %}
</div>