Skip to main content

Overview

The Program model is the central model in the ESP Website, representing educational programs such as Splash, HSSP, Junction, and Delve. Each program instance has its own URL, grade range, modules, and settings. Source: esp/esp/program/models/__init__.py:254

Model Fields

url
CharField
required
Unique URL identifier for the program (e.g., “Splash/2024”)
  • Max length: 80 characters
  • Must be unique across all programs
name
CharField
required
Display name of the program (e.g., “Splash 2024”)
  • Max length: 80 characters
grade_min
IntegerField
required
Minimum grade level allowed for student participation
grade_max
IntegerField
required
Maximum grade level allowed for student participation
director_email
EmailField
required
Director contact email address used for from field and display
  • Default: info@{SITE_INFO[1]}
  • Must end in your site domain or @learningu.org
  • Max length: 75 characters
director_cc_email
EmailField
Carbon-copy address for automated outgoing mail (except class cancellations)
  • If set, automated emails go here instead of director_email
  • Use to avoid spamming director email with teacher registration emails
  • Max length: 75 characters
director_confidential_email
EmailField
Email address for confidential communications like financial aid applications
  • If set, confidential emails go here instead of director_email
  • Max length: 75 characters
program_size_max
IntegerField
Maximum number of students allowed to register
  • Set to 0 for no cap
  • Performance is best when no cap is set
program_allow_waitlist
BooleanField
Whether to enable waitlist functionality when program is full
  • Default: False

Relationships

program_modules
ManyToManyField
Set of enabled program functionalities
class_categories
ManyToManyField
Categories available for organizing classes in this program
  • Links to: ClassCategories
  • Blank allowed
flag_types
ManyToManyField
Flag types that can be used to tag classes
  • Links to: ClassFlagType
  • Blank allowed
documents
GenericRelation
Media files and documents attached to the program
  • Links to: Media

Key Methods

URL Generation

get_absolute_url()
string
Returns the admin URL for the programReturns: /manage/{url}/mainExample:
program = Program.objects.get(url='Splash/2024')
print(program.get_absolute_url())  # "/manage/Splash/2024/main"
get_teach_url()
string
Returns the teacher-facing URLReturns: /teach/{url}/
get_learn_url()
string
Returns the student-facing URLReturns: /learn/{url}/
get_manage_url()
string
Returns the management URLReturns: /manage/{url}/
get_onsite_url()
string
Returns the onsite URLReturns: /onsite/{url}/

User Queries

students(QObjects=False)
dict
Returns dictionary of different sets of students for this programParameters:
  • QObjects (bool): If True, returns Q objects instead of querysets
Returns: OrderedDict with student categories (e.g., enrolled, registered)Example:
program = Program.objects.get(url='Splash/2024')
student_dict = program.students()
enrolled = student_dict.get('enrolled')
teachers(QObjects=False)
dict
Returns dictionary of different sets of teachers for this programParameters:
  • QObjects (bool): If True, returns Q objects instead of querysets
Returns: OrderedDict with teacher categories
volunteers(QObjects=False)
dict
Returns dictionary of different sets of volunteers for this programParameters:
  • QObjects (bool): If True, returns Q objects instead of querysets
Returns: OrderedDict with volunteer categories

Utility Methods

niceName()
string
Returns human-readable name of the programReturns: Value of the name field
grades()
list
Returns list of all grades eligible for the programReturns: List of integers from grade_min to grade_max (inclusive)Example:
program = Program.objects.get(url='Splash/2024')
program.grade_min = 7
program.grade_max = 12
print(program.grades())  # [7, 8, 9, 10, 11, 12]
isUsingStudentApps()
bool
Checks if this program uses student applicationsReturns: True if StudentAppQuestion objects exist for this programCached: Yes (depends on StudentAppQuestion model)

Properties

program_type
string
The type of program (first part of URL)Example: For url=“Splash/2024”, returns “Splash”
program_instance
string
The specific instance identifier (remaining parts of URL)Example: For url=“Splash/2024”, returns “2024”

Usage Examples

Creating a New Program

from esp.program.models import Program

program = Program.objects.create(
    url='Splash/2024',
    name='Splash 2024',
    grade_min=7,
    grade_max=12,
    director_email='[email protected]',
    program_size_max=1000,
    program_allow_waitlist=True
)

Getting Students in a Program

program = Program.objects.get(url='Splash/2024')

# Get all student categories
student_dict = program.students()

# Get count of students
student_counts = program.num_students()

for category, count in student_counts.items():
    print(f"{category}: {count} students")

Working with Program Modules

from esp.program.models import Program, ProgramModule

program = Program.objects.get(url='Splash/2024')

# Add a module to the program
student_reg_module = ProgramModule.objects.get(handler='StudentClassRegModule')
program.program_modules.add(student_reg_module)

# Check if program has a specific module
has_lottery = program.hasModule('StudentLotteryFrontendModule')

Accessing Program URLs

program = Program.objects.get(url='Splash/2024')

print(f"Students register at: {program.get_learn_url()}")
print(f"Teachers submit classes at: {program.get_teach_url()}")
print(f"Admins manage at: {program.get_manage_url()}")
  • ClassSubject - Classes offered in a program
  • User - Students, teachers, and administrators
  • Registration - Student enrollments in classes
  • Resources - Classrooms and equipment for the program

Build docs developers (and LLMs) love