Overview
The ESP resources system manages physical resources needed for programs:- ResourceType: Categories of resources (Classroom, Projector, etc.)
- Resource: Individual resources (specific classrooms, equipment)
- ResourceRequest: Requests for resources by classes
- ResourceAssignment: Assignment of resources to class sections
esp/esp/resources/models.py
ResourceType Model
Defines types/categories of resources available. Line:esp/esp/resources/models.py:69
Fields
Brief name of resource type
- Max length: 40 characters
- Examples: “Classroom”, “Projector”, “Computer[s]”
Detailed description of resource type
- What is this resource?
Whether resource is consumable/single-use
- Default: False
- Not fully implemented yet
Default priority/importance level
- Default: -1
- Higher numbers = more important
Whether to limit to one instance in some contexts
- Default: False
Pipe-delimited list of possible attribute values
- Example: “LCD projector|Overhead projector|Amplified speaker”
- Default: “Don’t care”
Program this resource type is specific to
- Links to:
Program - Null = global resource type available to all programs
Whether type was automatically created
- Default: False
Whether to hide from class creation forms
- Default: False
Methods
Gets existing type or creates new oneParameters:
label(string): Name of resource typeprogram(Program): Program for type, or None for global
Resource Model
Individual resource instances (specific classrooms, equipment pieces). Line:esp/esp/resources/models.py:161
Fields
Name/identifier of the resource
- Max length: 80 characters
- Examples: “Room 4-237”, “Projector A”
Type category of this resource
- Links to:
ResourceType - Cannot be null
Capacity (for classrooms)
- Default: -1 (not applicable)
- For classrooms: maximum number of students
Group of related resources
- Links to:
ResourceGroup - Resources in same group are bundled together
- Auto-created on save if not set
Whether resource is in its own group
- Default: False
- Set to True if res_group is auto-created
User associated with resource (for teacher availability)
- Links to:
ESPUser - Null for physical resources
Time block when resource is available
- Links to:
Event - Same resource at different times = separate Resource objects
Specific attribute value for this resource
- Corresponds to ResourceType.attributes_dumped options
- Example: “LCD projector” for A/V type
Key Methods
Checks if resource is available (not assigned)Parameters:
timeslot(Event): Check specific time, or use resource’s event if None
Checks if resource is currently assignedReturns: True if ResourceAssignment exists for this resource
Returns all Resources with same nameParameters:
prog(Program): Filter by program
Returns time blocks when resource is availableParameters:
program(Program): Filter by program
Assigns resource to a class sectionParameters:
section(ClassSection): Section to assign tooverride(bool): Clear existing assignments
clear_assignments()
Removes all assignments of this resourceExample:
Checks if resource satisfies class’s resource requestsParameters:
req_class(ClassSection): Section with resource requests
ResourceRequest Model
Request for a specific type of resource by a class. Line:esp/esp/resources/models.py:144
Fields
Class section requesting resource
- Links to:
ClassSection - Null if request is for ClassSubject
Class subject requesting resource
- Links to:
ClassSubject - Null if request is for ClassSection
Type of resource being requested
- Links to:
ResourceType
Specific attribute value desired
- Corresponds to ResourceType attributes
- Example: “LCD projector” for A/V type
Example
ResourceAssignment Model
Binding of a resource to a class section. Line:esp/esp/resources/models.py:352
Fields
Resource being assigned
- Links to:
Resource - Points to entire resource group
Class section receiving assignment
- Links to:
ClassSection - Null if assigned to ClassSubject
Class subject receiving assignment
- Links to:
ClassSubject - Null if assigned to ClassSection
Lock level for automatic scheduling
- Default: 0 (unlocked)
- Higher values = more resistant to changes
Whether floating resource has been returned
- Default: False
- Only relevant for non-classroom resources
Group of related assignments
- Links to:
AssignmentGroup - Auto-created on save
Methods
Returns all resources in same group as assigned resourceReturns: QuerySet of Resource objects
Returns most specific targetReturns: target if set, otherwise target_subj
Usage Examples
Setting Up Classrooms for a Program
Requesting Resources for a Class
Finding Available Classrooms
Assigning Resources to a Class
Checking Resource Fulfillment
Clearing and Reassigning Resources
Resource Usage Report
Related Models
- ClassSection - Sections that use resources
- Program - Programs that define resource availability
Event- Time blocks for resource availabilityResourceGroup- Groups related resourcesAssignmentGroup- Groups related assignments