Skip to content

Commit

Permalink
在书院课退选课、小组状态更改界面检查用户是否激活 (#827)
Browse files Browse the repository at this point in the history
* 在书院课退选课、小组状态更改界面检查用户是否激活

* 增加了成员申请时,检查是否已毕业

* 隐藏未激活用户边栏中的一些项目

隐藏了地下室预约、元气值商城、书院课程和新建小组。
  • Loading branch information
Deophius authored and pkuGenuine committed Aug 10, 2024
1 parent 1e8da84 commit fc1b3d0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/course_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ def selectCourse(request: HttpRequest):
wrong("非学生账号不能进行选课!", html_display)
return redirect(message_url(html_display, request.path))

if not request.user.active:
wrong("您已毕业,不能进行选课或退课操作!", html_display)
return redirect(message_url(html_display, request.path))

# 参数: 课程id,操作action: select/cancel
try:
course_id = request.POST.get('courseid')
Expand Down
6 changes: 6 additions & 0 deletions app/org_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def modifyOrganization(request: UserRequest):
if request.user.is_org():
return redirect(message_url(wrong("请不要使用小组账号申请新小组!")))

if not request.user.active:
return redirect(message_url(wrong("您已毕业,无法更改小组信息!")))

# ———————————————— 读取可能存在的申请 为POST和GET做准备 ————————————————

# 设置application为None, 如果非None则自动覆盖
Expand Down Expand Up @@ -280,6 +283,9 @@ def modifyPosition(request: UserRequest):
html_display = {}
me = get_person_or_org(request.user) # 获取自身

if not request.user.active:
return redirect(message_url(wrong("您的账号处于未激活状态,不能发起成员申请,如有需要请联系管理员!")))

# 前端使用量user_type,表示观察者是小组还是个人

# ———————————————— 读取可能存在的申请 为POST和GET做准备 ————————————————
Expand Down
1 change: 1 addition & 0 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def get_sidebar_and_navbar(user: User, navbar_name="", title_name=""):
bar_display["user_type"] = _utype
if user.is_staff:
bar_display["is_staff"] = True
bar_display["user_active"] = user.active

# 接下来填补各种前端呈现信息

Expand Down
8 changes: 8 additions & 0 deletions templates/user_left_navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
</div>
</a>
</li>
{% if bar_display.user_active %}
<li class="menu">
<a href="{{bar_display.underground_url}}" aria-expanded="false" class="dropdown-toggle">
<div class="">
Expand All @@ -39,6 +40,7 @@
</div>
</a>
</li>
{% endif %}
<li class="menu">
<a href="/feedback/" aria-expanded="false" class="dropdown-toggle">
<div class="">
Expand Down Expand Up @@ -80,9 +82,11 @@
<li>
<a href="{% url 'myPrize' %}">我的奖品</a>
</li>
{% if bar_display.user_active %}
<li>
<a href="{% url 'showPools' %}">元气值商城</a>
</li>
{% endif %}
</ul>
</li>
<li class="menu">
Expand All @@ -97,6 +101,7 @@
</div>
</a>
</li>
{% if bar_display.user_active %}
<li class="menu">
<a href="/selectCourse/" aria-expanded="false" class="dropdown-toggle">
<div class="">
Expand All @@ -109,6 +114,7 @@
</div>
</a>
</li>
{% endif %}