-
Notifications
You must be signed in to change notification settings - Fork 0
Models
Table of contents generated with markdown-toc
Represents an ESP program.
Fields:
-
name(CharField)- e.g.
"Spark"
- e.g.
-
edition(CharField)- e.g.
"2020"
- e.g.
-
student_reg_open(BooleanField)- Represents whether a new student can begin registration for the program.
-
student_reg_status(CharField)- Choices are
RegStatusOptions
- Choices are
-
url(property,string)- The URL that should be used for a given program, derived from
nameandedition
- The URL that should be used for a given program, derived from
Functions:
Represents a class for a program.
Fields:
-
title(CharField) -
description(TextField) -
capacity(PositiveIntegerField) -
program(Program)
Represents a section of a class.
Fields:
-
clazz(Class) -
number(PositiveIntegerField) -
program(property,Program)- The
Programassociated withclazz
- The
- num_students (property,
int)- The number of students enrolled in the section
Constraints:
-
clazzandnumberare a unique pair -
number_nonzero:number> 0
A Timeslot is a date x duration block during which a program is happening. The duration should be the smallest denomination of time that schedule offsets need to be able to accommodate.
Examples: A Splash where all classes are multiples of an hour may have 19 timeslots
- 2019/11/16 10:00–11:00, 11:00–12:00, and so on (for a total of 10)
- 2019/11/17 09:00–10:00, 10:00–11:00, and so on (for a total of 9)
An HSSP with 1-hour and 1.5-hour classes may have 42 timeslots (6 timeslots/day x 7 days/program)
- 2020/02/29 13:00–13:30, 13:30–14:00, ... , 15:30–16:00 (total of 6)
- and repeated for 2020/03/07, and so on (for 7 Saturdays)
Fields:
-
start(DateTimeField) -
end(DateTimeField) -
program(Program)
Constraints:
-
start,end, andprogramform a unique trio -
start_lt_end:start < end - Durations are constant for a given program
- Times are only a fixed set of values (e.g. on the hour/half hour)
-
startandendare in the same day
A ScheduledBlock represents a section of a class scheduled at a timeslot of a program in a particular classroom.
A 2-hour section scheduled in a program with 1-hour timeslot durations would be represented by two ScheduledBlock objects. A 1.5-hour section scheduled in a program with half-hour timeslot durations would be represented by three ScheduledBlock objects.
Represents the relationship between a student and a program, and everything that is a part of that.
Fields:
-
student(ESPUser) -
program(Program) -
student_reg_status(CharField)- Choices are
RegStatusOptions
- Choices are
-
update_profile_check(BooleanField)- Whether the student has updated their profile as a part of registration
-
emergency_info_check(BooleanField)- Whether the student has filled out the emergency contact information
-
liability_check(BooleanField)- Whether the student has filled out the liability waiver
-
medliab_check(BooleanField)- Whether the student has filled out the medical liability waiver
-
availability_check(BooleanField)- Whether the student has filled out their availability
-
payment_check(BooleanField)- Whether the student has taken care of payment for the program
-
classes(property,Classqueryset)- QuerySet of classes the student is enrolled in
Constraints:
-
studentandprogramform a unique pair student.is_student == True
Represents the relationship between a student(/studentreg) and a class section. If an object exists, the student is registered for that section.
Fields:
-
studentreg(StudentRegistration) -
section(Section) -
student(property,ESPUser)- The student connected to the
StudentRegistrationobject
- The student connected to the
-
program(property,Program)- The program connected to the
StudentRegistrationobject
- The program connected to the
Constraints:
-
studentregandsectionform a unique pair studentreg.program == section.program
Represents the relationship between a teacher and a program, and everything that is a part of that.
Fields:
-
teacher(ESPUser) -
program(Program) -
update_profile_check(BooleanField)- Whether the teacher has updated their profile as a part of registration
-
classes(property,Classqueryset)- QuerySet of classes the teacher is registered to teach for
Constraints:
-
teacherandprogramform a unique pair teacher.is_teacher == True
Represents the relationship between a teacher(/teacherreg) and a class. If an object exists, the teacher is registered to teach for that class.
Fields:
-
teacherreg(TeacherRegistration) -
clazz(Class) -
teacher(property,ESPUser)- The teacher connected to the
TeacherRegistrationobject
- The teacher connected to the
-
program(property,Program)- The program connected to the
TeacherRegistrationobject
- The program connected to the
Constraints:
-
teacherregandclazzform a unique pair teacherreg.program == clazz.program
This inherits from django.contrib.auth.models.AbstractUser. It is the type that is used for authentication. Every user on the website has an ESPUser object that represents their account.
Fields inherited from AbstractUser:
-
username(CharField) -
first_name(CharField) -
last_name(CharField) -
email(EmailField) -
is_staff(BooleanField)- Whether the user has access to the admin panel
-
is_superuser(BooleanField)- Whether the user can edit objects in the admin panel
-
is_student(property,boolean)- Whether the user has an attached
student_profile
- Whether the user has an attached
-
is_teacher(property,boolean)- Whether the user has an attached
teacher_profile
- Whether the user has an attached
-
profile(property,Profile)- The connected
Profileobject
- The connected
Constraints:
-
staff_equals_superuser(user.is_staff == user.is_superuser) - Object can have a student profile or a teacher profile, but not both (defined in
clean)
This is an abstract class. All user types inherit from it.
Fields:
-
phone_number(CharField) -
pronouns(CharField) -
city(CharField) -
state(CharField) -
country(CharField)
This inherits from Profile. It contains all the fields that only students have.
Fields:
-
user(OneToOneFieldmapped toESPUser, to connect the user and the profile) -
date_of_birth(DateField) -
grad_year(IntegerField) -
school(CharField)
-
user(OneToOneFieldmapped toESPUser, to connect the user and the profile) -
affiliation(CharField)
This is all possible student registration status options.
- CLASS_PREFERENCES (lottery selections)
- FROZEN_PREFERENCES (after lottery deadline, before FCFS opens)
- CHANGE_CLASSES (FCFS)
- PRE_PROGRAM (after FCFS deadline)
- DAY_OF (day of the program)
- POST_PROGRAM (after the program)
- EMPTY (only on the frontend, used to initialize the variable)
Full reference can be found here.
-
AutoField- Integer field that increments on each new element
- Used by IDs, probably not necessary to use directly
-
BooleanField(equivalent to pythonboolean) -
CharField(equivalent to pythonstring) DateFieldDateTimeField-
DurationField(for storing periods of time) EmailField-
FileField(for file uploads) FloatField-
ImageField(FileFieldbut only images) IntegerField-
PositiveIntegerField- includes
0as an option
- includes
-
SlugField- Basically a URL-friendly
string(e.g. no spaces)
- Basically a URL-friendly
-
TextField(for large amounts of text) TimeFieldURLField
-
ForeignKey- Allows the db to store a reference to another model
- Parameter:
-
to(the main required parameter): what model to reference -
on_delete: what to do if the reference model is deleted- This is usually
models.CASCADE
- This is usually
-
related_name: how to reference the collection of objects connected to the model being referenced, with a backwards reference- e.g. if a
Taghas anArticleforeign key, andrelated_name=tags, thenarticle.tagsreferences all the tags connected to an article - default is
[modelname]_set
- e.g. if a
-
related_query_name: analogous torelated_namebut for queries- e.g.
Article.objects.filter(tag__name="important")
- e.g.
-
-
OneToOneField- Essentially a
ForeignKey, but forces a one-to-one relationship, and using backwards references returns only one object
- Essentially a
Full reference can be found here.
-
verbose_name- Human-readable name for the object
- Defaults to converting camel case to spaced case
-
verbose_name_plural- Human-readable plural for the object
- Defaults to
verbose_name + "s"
-
unique_together- Tuple/list of tuples of fields in the object that together form a unique collection
- e.g.
Sectionhas aunique_togetherofclazzandnumber, so no otherSectioncan have the sameclazz-numberpair
-
ordering- Tuple/list of fields, in order of priority of how to default-order these objects in the admin panel/querysets
-
constraints- A list of constraints to define on the model.