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. 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¶
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
-
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.
-
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.
-
class
student.models.
RegistrationToken
(*args, **kwargs)[source]¶ A push notification token for Chrome noitification via Google Cloud Messaging
-
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).
Views¶
-
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]¶ Returns: 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.:
[{ "course_id":6137, "past_classmates":[...], "classmates":[...] }, ...]
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.
GCalView
(**kwargs)[source]¶ Handles interactions with the Google Calendar API V3 for pulling and/or sending calendars and calendar events.
-
class
student.views.
UserTimetableView
(**kwargs)[source]¶ Responsible for the viewing and managing of all Students’
PersonalTimetable
.
-
class
student.views.
UserView
(**kwargs)[source]¶ Handles the accessing and mutating of user information and preferences.
-
student.views.
accept_tos
(request)[source]¶ Accepts the terms of services for a user, saving the
datetime
the terms were accepted.
-
student.views.
create_unsubscribe_link
(student)[source]¶ 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.
Utils¶
-
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.
Parameters: - 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
ofStudents
) – 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.
- school (
-
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.
-
student.utils.
get_student
(request)[source]¶ Returns: the student belonging to the authenticated user Return type: ( Student
)
-
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.
Returns: the next weekday of the given type Return type: ( datetime.datetime
)