mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-04 03:22:06 +00:00
Merge branch 'dev' into new-arch
* dev: 修改禁止任何人加入的小组显示错误的问题 添加隐藏小组功能,但是只有超级管理员才能看到隐藏小组 对于已经加入的小组不再显示加入小组部分 对于已经加入的小组不再显示加入小组部分 修复创建者显示错误的问题
This commit is contained in:
commit
1612a4d63a
@ -17,6 +17,7 @@ class EditGroupSerializer(serializers.Serializer):
|
||||
name = serializers.CharField(max_length=20)
|
||||
description = serializers.CharField(max_length=300)
|
||||
join_group_setting = serializers.IntegerField()
|
||||
visible = serializers.BooleanField()
|
||||
|
||||
|
||||
class CreateJoinGroupRequestSerializer(serializers.Serializer):
|
||||
|
@ -25,7 +25,7 @@ class GroupAPIViewBase(object):
|
||||
管理员可以查询所有的小组,其他用户查询自己创建的自傲组
|
||||
"""
|
||||
if request.user.admin_type == SUPER_ADMIN:
|
||||
group = Group.objects.get(id=group_id, visible=True)
|
||||
group = Group.objects.get(id=group_id)
|
||||
else:
|
||||
group = Group.objects.get(id=group_id, visible=True, admin=request.user)
|
||||
return group
|
||||
@ -36,7 +36,7 @@ class GroupAPIViewBase(object):
|
||||
如果是管理员,就返回他创建的全部小组
|
||||
"""
|
||||
if request.user.admin_type == SUPER_ADMIN:
|
||||
groups = Group.objects.filter(visible=True)
|
||||
groups = Group.objects.filter()
|
||||
else:
|
||||
groups = Group.objects.filter(admin=request.user, visible=True)
|
||||
return groups
|
||||
@ -83,6 +83,7 @@ class GroupAdminAPIView(APIView, GroupAPIViewBase):
|
||||
group.name = data["name"]
|
||||
group.description = data["description"]
|
||||
group.join_group_setting = data["join_group_setting"]
|
||||
group.visible = data["visible"]
|
||||
group.save()
|
||||
except IntegrityError:
|
||||
return error_response(u"小组名已经存在")
|
||||
@ -298,7 +299,12 @@ def group_page(request, group_id):
|
||||
group = Group.objects.get(id=group_id, visible=True)
|
||||
except Group.DoesNotExist:
|
||||
return error_page(request, u"小组不存在")
|
||||
return render(request, "oj/group/group.html", {"group": group})
|
||||
joined = True
|
||||
try:
|
||||
UserGroupRelation.objects.get(user=request.user, group=group)
|
||||
except UserGroupRelation.DoesNotExist:
|
||||
joined = False
|
||||
return render(request, "oj/group/group.html", {"group": group, "joined": joined})
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -18,7 +18,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "validator"], function ($,
|
||||
name: "",
|
||||
description: "",
|
||||
checkedSetting: "0",
|
||||
|
||||
visible: true,
|
||||
getNext: function () {
|
||||
if (!vm.nextPage)
|
||||
return;
|
||||
@ -103,6 +103,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "validator"], function ($,
|
||||
vm.name = data.data.name;
|
||||
vm.description = data.data.description;
|
||||
vm.checkedSetting = data.data.join_group_setting.toString();
|
||||
vm.visible = data.data.visible;
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@ -123,7 +124,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "validator"], function ($,
|
||||
url: "/api/admin/group/",
|
||||
method: "put",
|
||||
data: {group_id: group_id, name: name, description: description,
|
||||
join_group_setting: join_group_setting},
|
||||
join_group_setting: join_group_setting, visible:vm.visible},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
|
@ -49,18 +49,24 @@
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-9">
|
||||
<div class="form-group">
|
||||
|
||||
<label>加入小组设置</label>
|
||||
<input type="radio" name="join_group_setting" value="0" ms-duplex-string="checkedSetting">允许任何人加入
|
||||
<input type="radio" name="join_group_setting" value="1" ms-duplex-string="checkedSetting">提交请求后管理员审核
|
||||
<input type="radio" name="join_group_setting" value="2" ms-duplex-string="checkedSetting">不允许任何人加入
|
||||
|
||||
<label>加入小组设置</label><br>
|
||||
<label><input type="radio" name="join_group_setting" value="0" ms-duplex-string="checkedSetting"><small>允许任何人加入</small></label>
|
||||
<label><input type="radio" name="join_group_setting" value="1" ms-duplex-string="checkedSetting"><small>提交请求后管理员审核</small></label>
|
||||
<label><input type="radio" name="join_group_setting" value="2" ms-duplex-string="checkedSetting"><small>不允许任何人加入</small></label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 form-group">
|
||||
<label>前台是否可见</label><br>
|
||||
<label><input type="checkbox" ms-duplex-checked="visible">
|
||||
<small>可见</small>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-primary" type="submit">提交</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<script src="/static/js/app/admin/group/groupDetail.js"></script>
|
||||
|
@ -22,14 +22,16 @@
|
||||
{% if user.userprofile.mood %}
|
||||
<p id="user-mood">{{ user.userprofile.mood }}</p>
|
||||
{% endif %}
|
||||
{% if user.userprofile.school %}
|
||||
<p id="user-mood">{{ user.userprofile.school }}</p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="list-group col-lg-9">
|
||||
|
||||
{% if user.userprofile.school %}
|
||||
<p class="list-group-item"> <span class="glyphicon glyphicon-education"></span>
|
||||
{{ user.userprofile.school }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if user.userprofile.blog %}
|
||||
<p class="list-group-item"><span class="glyphicon glyphicon-link"></span>
|
||||
<p class="list-group-item">
|
||||
<a href="{{ user.userprofile.blog }}" target="_blank">{{ blog_link }}</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<h2 class="text-center">{{ group.name }}</h2>
|
||||
|
||||
<p class="text-muted text-center">发布时间 : {{ group.create_time }}
|
||||
创建者 : {{ group.admin }}
|
||||
创建者 : {{ group.created_by }}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
@ -25,19 +25,23 @@
|
||||
<p class="group-detail">{{ group.description|safe }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% if not joined %}
|
||||
<hr>
|
||||
<div>
|
||||
{% if group.join_group_setting %}
|
||||
{% ifequal group.join_group_setting 1 %}
|
||||
<div class="form-group">
|
||||
<input id="groupId" value="{{ group.id }" type="hidden">
|
||||
<label>申请信息</label>
|
||||
<textarea class="form-control" id="applyMessage" rows="10"></textarea>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary" id="sendApplication">{% if group.join_group_setting %}申请{% endif %}加入</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block js_block %}
|
||||
|
@ -34,11 +34,15 @@
|
||||
<th scope="row"><a href="/group/{{ item.id }}/" target="_blank">{{ item.id }}</a></th>
|
||||
<td><a href="/group/{{ item.id }}/" target="_blank">{{ item.name }}</a></td>
|
||||
<td>
|
||||
{% if item.join_group_setting %}
|
||||
{% ifequal item.join_group_setting 1 %}
|
||||
需要申请
|
||||
{% else %}
|
||||
{% endifequal %}
|
||||
{% ifequal item.join_group_setting 0 %}
|
||||
无需申请
|
||||
{% endif %}
|
||||
{% endifequal %}
|
||||
{% ifequal item.join_group_setting 2 %}
|
||||
不允许加入
|
||||
{% endifequal %}
|
||||
</td>
|
||||
<td>{{ item.created_by }}</td>
|
||||
<td>{{ item.create_time }}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user