mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-01 10:02:01 +00:00
merge virusdefender-dev -> dev-s
This commit is contained in:
commit
d64659ec6f
@ -61,4 +61,14 @@ class ResetPasswordSerializer(serializers.Serializer):
|
||||
|
||||
|
||||
class SSOSerializer(serializers.Serializer):
|
||||
token = serializers.CharField(max_length=40)
|
||||
token = serializers.CharField(max_length=40)
|
||||
|
||||
|
||||
class EditUserProfileSerializer(serializers.Serializer):
|
||||
avatar = serializers.CharField(max_length=50, required=False, default=None)
|
||||
phone = serializers.CharField(min_length=11, max_length=11, required=False, allow_blank=True, default=None)
|
||||
blog = serializers.URLField(required=False, allow_blank=True, default=None)
|
||||
mood = serializers.CharField(max_length=60, required=False, allow_blank=True, default=None)
|
||||
hduoj_username = serializers.CharField(max_length=30, required=False, allow_blank=True, default=None)
|
||||
bestcoder_username = serializers.CharField(max_length=30, required=False, allow_blank=True, default=None)
|
||||
codeforces_username = serializers.CharField(max_length=30, required=False, allow_blank=True, default=None)
|
@ -17,12 +17,12 @@ from utils.captcha import Captcha
|
||||
from mail.tasks import send_email
|
||||
|
||||
from .decorators import login_required
|
||||
from .models import User
|
||||
from .serializers import (UserLoginSerializer, UsernameCheckSerializer,
|
||||
UserRegisterSerializer, UserChangePasswordSerializer,
|
||||
EmailCheckSerializer, UserSerializer, EditUserSerializer,
|
||||
from .models import User, UserProfile
|
||||
from .serializers import (UserLoginSerializer, UserRegisterSerializer,
|
||||
UserChangePasswordSerializer,
|
||||
UserSerializer, EditUserSerializer,
|
||||
ApplyResetPasswordSerializer, ResetPasswordSerializer,
|
||||
SSOSerializer)
|
||||
SSOSerializer, EditUserProfileSerializer)
|
||||
from .decorators import super_admin_required
|
||||
|
||||
|
||||
@ -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)
|
||||
@ -299,6 +300,28 @@ def user_index_page(request, username):
|
||||
return render(request, "oj/account/user_index.html", {"user": user, "blog_link": blog_link})
|
||||
|
||||
|
||||
class UserProfileAPIView(APIView):
|
||||
@login_required
|
||||
def put(self, request):
|
||||
serializer = EditUserProfileSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
data = serializer.data
|
||||
user_profile = request.user.userprofile
|
||||
|
||||
if data["avatar"]:
|
||||
user_profile.avatar = data["avatar"]
|
||||
user_profile.mood = data["mood"]
|
||||
user_profile.hduoj_username = data["hduoj_username"]
|
||||
user_profile.bestcoder_username = data["bestcoder_username"]
|
||||
user_profile.codeforces_username = data["codeforces_username"]
|
||||
user_profile.blog = data["blog"]
|
||||
|
||||
user_profile.save()
|
||||
return success_response(u"修改成功")
|
||||
else:
|
||||
return serializer_invalid_response(serializer)
|
||||
|
||||
|
||||
class SSOAPIView(APIView):
|
||||
def post(self, request):
|
||||
serializer = SSOSerializer(data=request.data)
|
||||
|
@ -6,7 +6,7 @@ from django.views.generic import TemplateView
|
||||
from account.views import (UserLoginAPIView, UsernameCheckAPIView, UserRegisterAPIView,
|
||||
UserChangePasswordAPIView, EmailCheckAPIView,
|
||||
UserAdminAPIView, UserInfoAPIView,
|
||||
ApplyResetPasswordAPIView, SSOAPIView)
|
||||
ApplyResetPasswordAPIView, SSOAPIView, UserProfileAPIView)
|
||||
|
||||
from announcement.views import AnnouncementAdminAPIView
|
||||
|
||||
@ -127,6 +127,7 @@ urlpatterns = [
|
||||
url(r'^account/settings/$', TemplateView.as_view(template_name="oj/account/settings.html"), name="account_setting_page"),
|
||||
url(r'^account/settings/avatar/$', TemplateView.as_view(template_name="oj/account/avatar.html"), name="avatar_settings_page"),
|
||||
url(r'^account/sso/$', SSOAPIView.as_view(), name="sso_api"),
|
||||
url('^api/account/userprofile/$', UserProfileAPIView.as_view(), name="userprofile_api"),
|
||||
]
|
||||
|
||||
|
||||
|
@ -294,7 +294,7 @@ def problem_list_page(request, page=1):
|
||||
return error_page(request, u"标签不存在")
|
||||
problems = tag.problem_set.all().filter(visible=True)
|
||||
|
||||
paginator = Paginator(problems, 20)
|
||||
paginator = Paginator(problems, 40)
|
||||
try:
|
||||
current_page = paginator.page(int(page))
|
||||
except Exception:
|
||||
|
@ -1,3 +1,41 @@
|
||||
/**
|
||||
* Created by uzi on 11/7/15.
|
||||
*/
|
||||
require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, csrfTokenHeader) {
|
||||
$('form').validator().on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()) {
|
||||
var phone = $("#phone").val();
|
||||
var hduoj_username = $("#hduoj_username").val();
|
||||
var bestcoder_username = $("#bestcoder_username").val();
|
||||
var codeforces_username = $("#codeforces_username").val();
|
||||
var blog = $("#blog").val();
|
||||
var mood = $("#mood").val();
|
||||
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/account/userprofile/",
|
||||
data: {
|
||||
phone: phone,
|
||||
hduoj_username: hduoj_username,
|
||||
bestcoder_username: bestcoder_username,
|
||||
codeforces_username: codeforces_username,
|
||||
blog: blog,
|
||||
mood: mood
|
||||
},
|
||||
dataType: "json",
|
||||
method: "put",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("修改成功");
|
||||
}
|
||||
else{
|
||||
bsAlert(data.data);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
bsAlert("额 好像出错了,请刷新页面重试。如还有问题,请填写页面导航栏上的反馈。")
|
||||
}
|
||||
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -75,6 +75,7 @@
|
||||
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"
|
||||
},
|
||||
shim: {
|
||||
avalon: {
|
||||
@ -159,7 +160,10 @@
|
||||
},
|
||||
{
|
||||
name: "group_22_pack"
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "settings_23_pack"
|
||||
},
|
||||
],
|
||||
optimizeCss: "standard",
|
||||
})
|
@ -77,6 +77,7 @@ var require = {
|
||||
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"
|
||||
},
|
||||
shim: {
|
||||
avalon: {
|
||||
|
@ -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"> {{ 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>
|
||||
|
@ -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>
|
||||
|
@ -1,21 +1,20 @@
|
||||
{% extends "oj_base.html" %}
|
||||
{% block title %}
|
||||
用户设置
|
||||
用户设置
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="container main">
|
||||
<div class="container main">
|
||||
|
||||
<div class="col-lg-2">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-header">通用设置</li>
|
||||
<li class="list-group-item active"><a href="/account/settings/">个人信息</a></li>
|
||||
<li class="list-group-item"><a href="/account/settings/avatar/">更换头像</a></li>
|
||||
<li class="list-group-item"><a href="/change_password/">修改密码</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-header">通用设置</li>
|
||||
<li class="list-group-item active"><a href="/account/settings/">个人信息</a></li>
|
||||
<li class="list-group-item"><a href="/account/settings/avatar/">更换头像</a></li>
|
||||
<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;">
|
||||
<img src="{{ user.userprofile.avatar }}" class="img-responsive index-avatar">
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<form>
|
||||
@ -23,62 +22,78 @@
|
||||
<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 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>
|
||||
<input name="phone" type="text" maxlength="11" id="phone"
|
||||
class="form-control"
|
||||
value="{% if request.user.userprofile.phone %}{{ request.user.userprofile.phone }}{% endif %}">
|
||||
</div>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label>学校</label>
|
||||
<input name="school" 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>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="form-group">
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
<div class="help-block with-errors"></div>
|
||||
<div class="form-group col-md-12">
|
||||
<label>签名</label>
|
||||
<input name="mood" type="text" maxlength="60" class="form-control" id="mood"
|
||||
value="{% if request.user.userprofile.mood %}{{ request.user.userprofile.mood }}{% endif %}"
|
||||
data-error="字数限制在30字以内">
|
||||
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block js_block %}
|
||||
<script src="/static/js/app/oj/account/settings.js"></script>
|
||||
{% endblock %}
|
||||
|
@ -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">
|
||||
|
||||
@ -32,7 +34,7 @@
|
||||
{% if user.userprofile.hduoj_username %}
|
||||
<p class="list-group-item">
|
||||
<img src="/static/img/oj_logo/hdu_logo.png" id="oj-logo">
|
||||
<a href="http://bestcoder.hdu.edu.cn/rating.php?user={{ user.userprofile.hduoj_username }}" target="_blank">
|
||||
<a href="http://acm.hdu.edu.cn/userstatus.php?user={{ user.userprofile.hduoj_username }}" target="_blank">
|
||||
{{ user.userprofile.hduoj_username }}
|
||||
</a>
|
||||
</p>
|
||||
@ -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>
|
||||
|
@ -61,9 +61,11 @@
|
||||
<ul class="dropdown-menu">
|
||||
{% if request.user.admin_type > 0 %}
|
||||
<li><a href="/admin/">后台管理</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
{% endif %}
|
||||
<li><a href="/user/{{ request.user.username }}/">我的主页</a></li>
|
||||
<li><a href="/submissions/">我的提交</a></li>
|
||||
<li><a href="#">我的资料</a></li>
|
||||
<li><a href="/account/settings/">设置</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="/logout/">退出</a></li>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user