borrowings Classroom Reservations & Approval¶
Author: Zhenyu Yang yangzhenyu@sust.edu.cn, Sixu Wei reisa@sust.edu.cn
Last updated: Apr 24, 2026
Corresponding API docs: Classroom Reservation API
borrowings Code Entry¶
backend/apps/borrowings/models/__init__.pybackend/apps/borrowings/views/__init__.pybackend/apps/borrowings/services/__init__.py
borrowings Core Data¶
BorrowApplication¶
Key fields:
applicantreviewer_roleclassroomstart_time/end_timereasonexpected_studentsstatussource_typeactivity_typereview_levelis_urgentauto_generated
List Visibility¶
The list is not simply split by admin vs. non-admin; it is routed by the current active role current_role:
student: Can only see their own applications.chinese_teacher/foreign_teacher: Can only see their own applications; defaults tosource_type=manualonly.counselor: Defaults to first-review student activities;mine=trueshows their own applications.secretary: Defaults to first-review teaching activities;mine=trueshows their own applications.assistant: Defaults to second-review applications;mine=trueshows their own applications.superadmin: Defaults to all;mine=trueshows only their own applications.
Creation Rules¶
Privileged roles (
superadmin/secretary/assistant) can submit on behalf of others usingapplicant_idorapplicant_code.On creation, the system validates:
The time range is valid.
The applicant’s role matches the
activity_type.The time window complies with role-based restrictions.
The expected number of attendees does not exceed the classroom capacity.
No conflicts with manual reservations or course occupancy.
Approval Flow¶
The initial approval route is determined by
activity_type:student_activity-> first review bycounselorteaching_activity-> first review bysecretary
Applications created by
assistant/superadmingo directly to the second-review queue.After first review approval, the application automatically moves to second review by
assistant.After second review approval, the status becomes
approved.superadmincan directly grant final approval.Self-review rules:
assistantandsuperadminmay review their own applications.Other roles are not allowed to approve their own applications.
Cancellation & Rescheduling¶
Cancellation¶
Only the applicant themselves can cancel.
Cancellation is not allowed if less than 6 hours remain before the start time.
Course Reservation Rescheduling¶
Entry:
POST /borrow/{id}/rescheduleOnly allowed when:
source_type=coursestatus=approved
Current implementation, within a transaction:
Marks the original application as
cancelled.Creates a new, already-approved
source_type=courseapplication.
Relationship with the Courses Module¶
Conflict detection checks both:
Manual reservations
CourseOccurrence
When rescheduling, both the courses and borrowings modules have their own rescheduling endpoints for different use cases:
coursesrescheduling changes the course instance.borrowingsrescheduling changes the reservation record derived from a course.