app.academic_utils module¶
- app.academic_utils.audit_academic_map(author: NaturalPerson) None [源代码]¶
审核通过某用户的记录。 :param author: 被审核用户 :type author: NaturalPerson
- app.academic_utils.chats2Display(user: User, sent: bool) dict[str, list[dict]] [源代码]¶
把我收到/我发出的所有chat转化为供前端展示的两个列表,分别是进行中chat的信息、和其他chat的信息
- 参数:
chats (QuerySet[Chat]) -- 我收到/我发出的所有chat
sent (bool) -- 若为True则表示我发出的,否则表示我收到的
- 返回:
一个词典,key为progressing和not_progressing,value分别是进行中chat的列表、和其他chat的列表
- 返回类型:
dict[str, list[dict]]
- app.academic_utils.comments2display(chat: Chat, user: User) dict [源代码]¶
获取一个chat中的所有comment并转化为前端展示所需的形式(复用了comment_utils.py/showComment)
- app.academic_utils.get_js_tag_list(author: NaturalPerson, type: Type, selected: bool, status_in: list[EntryStatus] | None = None) list[dict] [源代码]¶
用于前端显示支持搜索的专业/项目列表,返回形如[{id, content}]的列表。
- 参数:
author (NaturalPerson) -- 作者自然人信息
type (AcademicTag.Type) -- 标记所需的tag类型
selected (bool) -- 用于标记是否获取本人已有的专业项目,selected代表获取前端默认选中的项目
status_in (list[AcademicEntry.EntryStatus]) -- 所要检索的状态的列表,默认为None,表示搜索全部
- 返回:
所有专业/项目组成的List[dict],key值如上所述
- 返回类型:
list[dict]
- app.academic_utils.get_search_results(query: str) dict[str, dict[str, list[str]]] [源代码]¶
根据提供的关键词获取搜索结果。
- app.academic_utils.get_tag_status(person: NaturalPerson, type: Type) str [源代码]¶
获取person的类型为type的TagEntry的公开状态。 如果person没有类型为type的TagEntry,返回"公开"。
- 参数:
person (NaturalPerson) -- 需要获取公开状态的人
type (AcademicTag.Type) -- TagEntry的类型
- 返回:
公开状态,返回"公开/私密"
- 返回类型:
str
- app.academic_utils.get_text_list(author: NaturalPerson, type: Type, status_in: list[EntryStatus] | None = None) list[str] [源代码]¶
获取自己的所有类型为type的TextEntry的内容列表。
- 参数:
author (NaturalPerson) -- 作者自然人信息
type (AcademicTextEntry.Type) -- TextEntry的类型
status_in (list) -- 所要检索的状态的列表,默认为None,表示搜索全部
- 返回:
含有所有类型为type的TextEntry的content的list
- 返回类型:
list[str]
- app.academic_utils.get_text_status(person: NaturalPerson, type: Type) str [源代码]¶
获取person的类型为type的TextEntry的公开状态。 如果person没有类型为type的TextEntry,返回"公开"。
- 参数:
person (NaturalPerson) -- 需要获取公开状态的人
type (AcademicTextEntry.Type) -- TextEntry的类型
- 返回:
公开状态,返回"公开/私密"
- 返回类型:
str
- app.academic_utils.get_wait_audit_student() set[NaturalPerson] [源代码]¶
获取当前审核中的AcademicEntry对应的学生,因为要去重,所以返回一个集合
- 返回:
当前审核中的AcademicEntry对应的NaturalPerson组成的集合
- 返回类型:
set[NaturalPerson]
- app.academic_utils.have_entries(author: NaturalPerson, status_in: list[EntryStatus]) bool [源代码]¶
判断用户有无status属性为public/wait_audit...的学术地图条目(tag和text) :param author: 条目作者用户 :type author: NaturalPerson :param status_in: AcademicEntry.EntryStatus构成的list :type status_in: list[AcademicEntry.EntryStatus] :return: 是否有该类别的条目 :rtype: bool
- app.academic_utils.update_academic_map(request: HttpRequest) dict [源代码]¶
从前端获取填写的学术地图信息,并在数据库中进行更新,返回含有成功/错误信息的dict。
- 参数:
request (HttpRequest) -- http请求
- 返回:
含成功/错误信息的dict,用于redirect后页面的前端展示
- 返回类型:
dict
- app.academic_utils.update_tag_entry(person: NaturalPerson, tag_ids: list[str], status: bool, type: Type) None [源代码]¶
更新TagEntry的工具函数。
- 参数:
person (NaturalPerson) -- 需要更新学术地图的人
tag_ids (list[str]) -- 含有一系列tag_id(未经类型转换)的list
status (bool) -- tag_ids对应的所有tags的公开状态
type (AcademicTag.Type) -- tag_ids对应的所有tags的类型
- app.academic_utils.update_text_entry(person: NaturalPerson, contents: list[str], status: bool, type: Type) None [源代码]¶
更新TextEntry的工具函数。
- 参数:
person (NaturalPerson) -- 需要更新学术地图的人
tag_ids (list[str]) -- 含有一系列TextEntry的内容的list
status (bool) -- 该用户所有类型为type的TextEntry的公开状态
type (AcademicTextEntry.Type) -- contents对应的TextEntry的类型