Skip to content

Commit

Permalink
Fix org apply
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuGenuine committed Jan 5, 2025
1 parent 487e2e3 commit e6fe33c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
16 changes: 16 additions & 0 deletions app/migrations/0003_remove_modifyorganization_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 5.0.9 on 2025-01-05 16:54

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("app", "0002_delete_freshman"),
]

operations = [
migrations.RemoveField(
model_name="modifyorganization",
name="tags",
),
]
1 change: 0 additions & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,6 @@ class Status(models.IntegerChoices): # 表示申请小组的请求的状态
REFUSED = (3, "已拒绝")

status = models.SmallIntegerField(choices=Status.choices, default=0)
tags = models.CharField(max_length=100, default='', blank=True)

def __str__(self):
# YWolfeee: 不认为应该把类型放在如此重要的位置
Expand Down
14 changes: 7 additions & 7 deletions app/org_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def find_max_oname():
organizations = Organization.objects.filter(
organization_id__username__startswith="zz"
).order_by("-organization_id__username")
if not organizations.exists():
# TODO: remove hard code
return "zz10001"
max_org: Organization = organizations[0]
max_oname = str(max_org.get_user().username)
max_oname = int(max_oname[2:]) + 1
Expand Down Expand Up @@ -223,7 +226,6 @@ def update_org_application(application: ModifyOrganization, me: NaturalPerson, r
pos=me.person_id,
introduction=info.get('introduction'),
application=info.get('application'),
tags=info.get('tags_modify')
)
if context["avatar"] is not None:
application.avatar = context['avatar'];
Expand All @@ -242,16 +244,14 @@ def update_org_application(application: ModifyOrganization, me: NaturalPerson, r
if (application.oname == info.get("oname")
and application.introduction == info.get('introduction')
and application.avatar == info.get('avatar', None)
and application.application == info.get('application')
and application.tags == info.get('tags_modify')):
and application.application == info.get('application')):
return wrong("没有检测到修改!")
# 至此可以发起修改
ModifyOrganization.objects.filter(id=application.id).update(
oname=info.get('oname'),
#otype=OrganizationType.objects.get(otype_name=info.get('otype')),
introduction=info.get('introduction'),
application=info.get('application'),
tags=info.get('tags_modify'))
application=info.get('application'))
if context["avatar"] is not None:
application.avatar = context['avatar']
application.save()
Expand Down Expand Up @@ -513,8 +513,8 @@ def make_relevant_notification(application: ModifyPosition | ModifyOrganization,
else:
raise NotImplementedError
applyer_id = apply_person.person_id
# 小组申请现在由运营初步审核,所以通知发给智慧书院小组
applyee_id = User.objects.get(username = GLOBAL_CONFIG.official_uid)
# Revert to incharge id
applyee_id = inchage_person.person_id
not_type = Notification.Title.NEW_ORGANIZATION
URL = f'/modifyOrganization/?org_id={application.id}'

Expand Down
5 changes: 1 addition & 4 deletions app/org_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@ def modifyOrganization(request: UserRequest):

# 处理通知相关的操作,并根据情况发送微信
# 默认需要成功,失败也不是用户的问题,直接给管理员报错 TODO
try:
make_relevant_notification(application, request.POST)
except:
raise NotImplementedError
make_relevant_notification(application, request.POST)

elif context["warn_code"] != 1: # 没有返回操作提示
raise NotImplementedError("处理小组申请中出现未预见状态,请联系管理员处理!")
Expand Down

0 comments on commit e6fe33c

Please sign in to comment.