Appointment.utils.web_func module

YWolfeee: web_func.py中保留所有在views.py中使用到了和web发生交互但不直接在urls.py中暴露的函数 这些函数是views.py得以正常运行的工具函数。 函数比较乱,建议实现新函数时先在这里面找找有没有能用的。

Appointment.utils.web_func.appointment2Display(appoint: Appoint, type: str, userid: str = None) Dict[str, Any][源代码]

获取单次预约的信息,填入供前端展示的词典

参数:
  • appoint (Appoint) -- 单次预约

  • type (str) -- 展示类型

  • userid (str) -- 预约人id,长期预约不需要

返回:

供前端展示的词典

返回类型:

dict[str, Any]

Appointment.utils.web_func.appoints2json(appoints: QuerySet | Appoint)[源代码]
Appointment.utils.web_func.get_appoints(Pid, kind: str, major=False)[源代码]
  • Pid: Participant, User or str

  • kind: 'future', 'past' or 'violate'

  • returns: objs.toJson() form or None if failed

Appointment.utils.web_func.get_dayrange(span: int = 7, day_offset: int = 0)[源代码]

生成一个连续的时间段

参数:
  • span (int) -- 时间段跨度, defaults to 7

  • day_offset (int) -- 开始时间与当前时间相差的天数, defaults to 0

返回:

时间段列表,每一项包含该天的具体信息、起始日期、结束后下一天

返回类型:

list[dict], date, date

Appointment.utils.web_func.get_hour_time(room, timeid)[源代码]
Appointment.utils.web_func.get_talkroom_timerange(talk_room_list)[源代码]

returns :talk toom 的时间range 以及最早和最晚的时间 int, datetime.time, datetime.time

Appointment.utils.web_func.get_time_id(room: Room, ttime: time, mode: str = 'rightopen') int[源代码]

返回当前时间的时间块编号,注意编号会与房间的开始预定时间相关。

参数:
  • room (Room) -- 房间

  • ttime (time) -- 当前时间

  • mode (str) -- 左开右闭或左闭右开, defaults to "rightopen"

返回:

当前时间所处的时间块编号

返回类型:

int

Appointment.utils.web_func.get_user_info(Pid)[源代码]

抓取用户信息的通用包,成功返回包含id, name, credit的字典

Appointment.utils.web_func.time2datetime(year, month, day, t)[源代码]
Appointment.utils.web_func.timerange2idlist(Rid, Astart, Afinish, max_id)[源代码]