Section capacity is determined by multiple factors (in priority order):
max_class_capacity - Section-specific override
Room capacity - Limited by assigned classroom size
class_size_max - Parent class maximum
class_size_optimal - Preferred class size
section.capacity # Computed property considering all factorssection.num_students() # Current enrollment countsection.isFull() # Is the section at capacity?
The capacity calculation is intelligent - it takes the minimum of the room size and class maximum, then applies program-wide multipliers if configured.
A single ClassSubject can have multiple ClassSections:
# Get all sections of a classclass_subject.sections.all()class_subject.get_sections() # Cached version# Access parent class from sectionsection.parent_class
# Get when a section meetssection.meeting_times.all() # QuerySet of Event objectssection.start_time() # First meeting timesection.end_time() # Last meeting time# Check if scheduledsection.isScheduled() # True if has meeting times
# Get assigned classroomssection.classrooms() # QuerySet of Resource objectssection.prettyrooms() # List of room names# Assign a roomsection.assign_room(classroom_resource)# Clear room assignmentssection.clearRooms()
status = section.scheduling_status()# Returns:# - "Happy" - Fully scheduled with all resources# - "Needs time" - No meeting times assigned# - "Needs room" - Has times but no classroom# - "Needs resources" - Missing requested resources (projector, etc.)
# Students enrolled in a sectionsection.students() # Default: enrolled studentssection.students_prereg() # All registration typessection.num_students() # Count of enrolled students# Students enrolled in any section of a classclass_subject.students() # Across all sections
# Check if section is fullif section.isFull(): print("Section at capacity")# Check if specific student can adderror = section.cannotAdd(student)if error: print(f"Cannot add: {error}")else: # Student can be added pass
# All classes in a programprogram.classes()# Approved classes onlyClassSubject.objects.filter( parent_program=program, status=ClassStatus.ACCEPTED)# Classes by teacherteacher.getTaughtClasses(program)# Classes by categoryClassSubject.objects.filter( parent_program=program, category__symbol='M' # Math classes)
if program.useGradeRangeExceptions(): # Check if student has override permission if student.hasGradeOverride(program): # Allow registration despite grade restriction pass
# Find times when all teachers are availablesection.viable_times()# Returns Event objects where all teachers indicated availability# and are not teaching other classes
# For a scheduled section, find rooms that fitviable_rooms = section.viable_rooms()# Returns rooms that:# - Are available at all meeting times# - Have sufficient capacity# - Satisfy resource requests (projector, etc.)
# Get class capacity considering all factorsdef _get_capacity(self, ignore_changes=False): ans = None rooms = self.classrooms() if self.max_class_capacity is not None: ans = self.max_class_capacity else: if len(rooms) == 0: ans = self.parent_class.class_size_max else: class_max = self.parent_class.class_size_max room_cap = self._get_room_capacity(rooms) ans = min(class_max, room_cap) if class_max and room_cap else class_max or room_cap # Apply program-wide capacity adjustments options = self.parent_program.studentclassregmoduleinfo if not ignore_changes: ans = int(ans * options.class_cap_multiplier + options.class_cap_offset) return int(ans) if ans else 0