Student App

The Student model is an abstraction over the Django user to provide us with a more full user profile including information pulled from social authentication via Google and/or Facebook (and/or Microsoft JHED at JHU). This app handles utilities for overriding the Python Social Auth authentication pipeline, while also handling the functionality for logged in users.

The student app also encapsulates all models tied directly to a user like PersonalTimetables, PersonalEvents, Reactions, and notification tokens.


Models pertaining to Students.

class student.models.PersonalEvent(*args, **kwargs)[source]

A custom event that has been saved to a user’s PersonalTimetable so that it persists across refresh, device, and session. Marks when a user is not free. Courses are scheduled around it.abs

exception DoesNotExist
exception MultipleObjectsReturned
class student.models.PersonalTimetable(*args, **kwargs)[source]

Database object representing a timetable created (and saved) by a user.

A PersonalTimetable belongs to a Student, and contains a list of Courses and Sections that it represents.

exception DoesNotExist
exception MultipleObjectsReturned
class student.models.PilotOffering(id, day, date_start, date_end, time_start, time_end, size, enrolment, waitlist, course_name)[source]
exception DoesNotExist
exception MultipleObjectsReturned
class student.models.Reaction(*args, **kwargs)[source]

Database object representing a reaction to a course.

A Reaction is performed by a Student on a Course, and can be one of REACTION_CHOICES below. The reaction itself is represented by its title field.

exception DoesNotExist
exception MultipleObjectsReturned
class student.models.RegistrationToken(*args, **kwargs)[source]

A push notification token for Chrome noitification via Google Cloud Messaging

exception DoesNotExist
exception MultipleObjectsReturned
class student.models.Student(*args, **kwargs)[source]

Database object representing a student.

A student is the core user of the app. Thus, a student will have a class year, major, friends, etc. An object is only created for the user if they have signed up (that is, signed out users are not represented by Student objects).

exception DoesNotExist
exception MultipleObjectsReturned


class student.views.ClassmateView(**kwargs)[source]

Handles the computation of classmates for a given course, timetable, or simply the count of all classmates for a given timetable.

get(request, sem_name, year)[source]

If the query parameter ‘count’ is present Information regarding the number of friends only:

    "id": Course with the most friends,
    "count": The maximum # of friends in a course,
    "total_count": the total # in all classes on timetable,

If the query parameter course_ids is present a list of dictionaries representing past classmates and current classmates. These are students who the authenticated user is friends with and who has social courses enabled.:

}, ...]

Otherwise a list of friends and non-friends alike who have social_all enabled to be dispalyed in the “find-friends” modal. Sorted by the number courses the authenticated user shares.:

    "name": "...",
    "is_friend": Whether or not the user is current user's friend,
    "profile_url": link to FB profile,
    "shared_courses": [...],
    "peer": Info about the user,
}, ...]

class student.views.ReactionView(**kwargs)[source]

Manages the creation of Reactions to courses.


Create a Reaction for the given course id, with the given title matching one of the possible emojis. If already present, remove that reaction.

class student.views.UserTimetableView(**kwargs)[source]

Responsible for the viewing and managing of all Students’ PersonalTimetable.

delete(request, sem_name, year, tt_name)[source]

Deletes a PersonalTimetable by name/year/term.

get(request, sem_name, year)[source]

Returns student’s personal timetables


Duplicates a personal timetable if a ‘source’ is provided. Else, creates a personal timetable based on the courses, custom events, preferences, etc. which are provided.

update_events(tt, events)[source]

Replace tt’s events with input events. Deletes all old events to avoid buildup in db

class student.views.UserView(**kwargs)[source]

Handles the accessing and mutating of user information and preferences.


Delete this user and all of its data


Renders the user profile/stats page which indicates all of a student’s reviews of courses, what social they have connected, whether notificaitons are enabled, etc.


Updates a user settings to match the corresponding values passed in the request body. (e.g. social_courses, class_year, major)


Accepts the terms of services for a user, saving the datetime the terms were accepted.

Generates a unsubscribe link which directs to the student unsubscribe view.

student.views.get_friend_count_from_course_id(school, student, course_id, semester)[source]

Computes the number of friends a user has in a given course for a given semester.

Ignores whether or not those friends have social courses enabled. Never exposes those user’s names or infromation. This count is used purely to upsell user’s to enable social courses.


Logs that a calendar was exported on the frotnend and indicates it was downloaded rather than exported to Google calendar.

student.views.unsubscribe(request, student_id, token)[source]

If the student matches the token and the tokens is valid , unsubscribes user from emails marking student.emails_enabled to false. Redirects to index.


student.utils.get_classmates_from_course_id(school, student, course_id, semester, friends=None, include_same_as=False)[source]

Get’s current and past classmates (students with timetables containing the provided course ID). Classmates must have social_courses enabled to be included. If social_sections is enabled, info about what section they are in is also passed.

  • school (str) – the school code (e.g. ‘jhu’)

  • student (Student) – the student for whom to find classmates

  • course_id (int) – the database id for the course

  • semester (Semester) – the semester that is current (to check for)

  • friends (list of Students) – if provided, does not re-query for friends list, uses provided list.

  • include_same_as (bool) – If provided as true, searches for classmates in any courses marked as “same as” in the database.

student.utils.get_classmates_from_tts(student, course_id, tts)[source]

Returns a list of classmates a student has from a list of other user’s timetables. This utility does the leg work for get_classmates_from_course_id() by taking either a list of current or past timetables and finding classmates relevant to that list.

If both students have social_offerings enabled, adds information about what sections the student is enrolled in on each classmate.


the student belonging to the authenticated user

Return type


student.utils.get_student_tts(student, school, semester)[source]

Returns serialized list of a student’s PersonalTimetable objects ordered by last updated for passing to the frontend.

student.utils.next_weekday(d, weekday)[source]

Given a current date, d, and a target weekday, calculate the next occurence (moving in the future) of that weekday.


the next weekday of the given type

Return type



class student.serializers.StudentSerializer(*args, **kwargs)[source]
student.serializers.get_student_dict(school, student, semester)[source]

Return serialized representation of a student.