app package

Submodules

app.models module

class app.models.Course(**kwargs)[source]

Bases: Model

Represents a course (class) in the application. Stores local overrides and settings for a Google Classroom course.

id

Primary key.

Type:

int

user_id

Foreign key to the User.

Type:

int

google_course_id

ID of the course in Google Classroom.

Type:

str

custom_name

User-defined name for the course.

Type:

str

custom_section

User-defined section for the course.

Type:

str

custom_code

User-defined class code (enrollment code).

Type:

str

custom_banner

URL to a custom banner image.

Type:

str

custom_icon

URL to a custom icon.

Type:

str

cached_teacher_name

Cached name of the teacher from Google.

Type:

str

custom_teacher_name

User-defined teacher name.

Type:

str

is_archived

Whether the course is archived locally.

Type:

bool

is_pinned

Whether the course is pinned (not currently used).

Type:

bool

display_order

Order index for display sorting.

Type:

int

user_tags

List of UserTags associated with this course.

Type:

list

cached_teacher_name
custom_banner
custom_code
custom_icon
custom_name
custom_section
custom_teacher_name
display_order
google_course_id
id
is_archived
is_pinned
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

user_id
user_tags
class app.models.CourseTag(**kwargs)[source]

Bases: Model

Represents a tag specific to a course, used for tagging items within that course. (Note: This seems to be a legacy or specific-use tag, distinct from UserTag).

id

Primary key.

Type:

int

course_id

Foreign key to the Course.

Type:

int

name

Name of the tag.

Type:

str

color

Color code for the tag.

Type:

str

color
course
course_id
id
name
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

class app.models.ItemTag(**kwargs)[source]

Bases: Model

Associates a CourseTag with a specific item (assignment/material) in Google Classroom.

id

Primary key.

Type:

int

tag_id

Foreign key to the CourseTag.

Type:

int

google_item_id

ID of the item in Google Classroom.

Type:

str

google_item_id
id
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

tag
tag_id
class app.models.MutedItem(**kwargs)[source]

Bases: Model

Represents an item (assignment) that a user has muted/hidden from the ‘Missing Assignments’ list.

id

Primary key.

Type:

int

user_id

Foreign key to the User.

Type:

int

google_item_id

ID of the item in Google Classroom.

Type:

str

google_item_id
id
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

user_id
class app.models.User(**kwargs)[source]

Bases: UserMixin, Model

Represents a user of the application.

id

Primary key.

Type:

int

google_id

Unique Google ID of the user.

Type:

str

email

User’s email address.

Type:

str

name

User’s full name.

Type:

str

picture

URL to the user’s profile picture.

Type:

str

_access_token

Encrypted OAuth access token.

Type:

str

_refresh_token

Encrypted OAuth refresh token.

Type:

str

token_expiry

Expiration time of the access token.

Type:

datetime

token_uri

URI for token refreshing.

Type:

str

_client_id

Encrypted OAuth client ID.

Type:

str

_client_secret

Encrypted OAuth client secret.

Type:

str

scopes

Comma-separated list of granted OAuth scopes.

Type:

str

courses

Relationship to the user’s courses.

Type:

dynamic

property access_token

Decrypted OAuth access token.

property client_id

Decrypted OAuth client ID.

property client_secret

Decrypted OAuth client secret.

courses
email
google_id
id
name
picture
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

property refresh_token

Decrypted OAuth refresh token.

scopes
token_expiry
token_uri
class app.models.UserTag(**kwargs)[source]

Bases: Model

Represents a global tag created by a user to organize their courses.

id

Primary key.

Type:

int

user_id

Foreign key to the User.

Type:

int

name

Name of the tag.

Type:

str

id
name
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

user_id
app.models.decrypt_value(value)[source]

Decrypts an encrypted string value using the application’s cipher suite.

Parameters:

value (str) – The encrypted string to decrypt.

Returns:

The decrypted string, or the original value if decryption fails or value is None.

Return type:

str

app.models.encrypt_value(value)[source]

Encrypts a string value using the application’s cipher suite.

Parameters:

value (str) – The string to encrypt.

Returns:

The encrypted string, or the original value if encryption fails or value is None.

Return type:

str

app.models.get_cipher_suite()[source]

Generates a Fernet cipher suite based on the application’s SECRET_KEY.

Returns:

A Fernet instance for encryption/decryption. None: If an error occurs during key generation.

Return type:

cryptography.fernet.Fernet

app.routes module

app.routes.archived_courses()[source]

Renders the archived courses page.

Displays courses that are either archived in Google Classroom or locally archived by the user.

Returns:

Rendered HTML template for archived courses.

Return type:

str

app.routes.callback()[source]

Handles the callback from Google OAuth.

Exchanges the authorization code for tokens, fetches user info, creates/updates the user record in the database, and logs the user in.

Returns:

Redirects to the index page upon success.

Return type:

redirect

app.routes.course_stream(course_id)[source]

Renders the stream view for a specific course.

Fetches announcements, coursework, and materials from Google Classroom. Merges with local tag data.

Parameters:

course_id (str) – The Google Course ID.

Returns:

Rendered HTML template for the course stream.

Return type:

str

app.routes.create_tag(course_id)[source]

Creates a new tag for a specific course (Legacy/Specific Tag).

Parameters:

course_id (str) – The Google Course ID.

Returns:

Redirects back to the course stream.

Return type:

redirect

app.routes.delete_tag(course_id, tag_id)[source]

Deletes a specific course tag.

Parameters:
  • course_id (str) – The Google Course ID.

  • tag_id (int) – The ID of the tag to delete.

Returns:

Redirects back to the course stream.

Return type:

redirect

app.routes.edit_course(course_id)[source]

Handles editing of course settings (name, section, tags, etc.).

Parameters:

course_id (str) – The Google Course ID.

Returns:

Rendered HTML template for the edit form or a redirect.

Return type:

str

app.routes.get_file_icon(mime_type, title=None)[source]

Determines the appropriate Font Awesome icon class for a given file MIME type.

Parameters:
  • mime_type (str) – The MIME type of the file (e.g., ‘application/pdf’).

  • title (str, optional) – The title of the file (unused, but kept for compatibility).

Returns:

A string containing the CSS classes for the icon (e.g., ‘file-pdf text-red-500’).

Return type:

str

app.routes.index()[source]

Renders the main dashboard (index) page.

Fetches the user’s courses from Google Classroom, merges them with local database overrides, checks for new assignments, and handles display sorting and filtering.

Returns:

Rendered HTML template for the dashboard.

Return type:

str

app.routes.load_user(id)[source]

Flask-Login user loader callback.

Parameters:

id (str) – The user ID from the session.

Returns:

The User object corresponding to the ID.

Return type:

User

app.routes.login()[source]

Initiates the Google OAuth login flow.

Returns:

Redirects the user to Google’s authorization URL.

Return type:

redirect

app.routes.logout()[source]

Logs the user out.

Returns:

Redirects to the index page.

Return type:

redirect

app.routes.missing_assignments()[source]

Renders the missing assignments page.

Fetches all coursework from active courses, checks submission status, and identifies missing items. Filters out items that the user has locally muted.

Returns:

Rendered HTML template for missing assignments.

Return type:

str

app.routes.sync_calendar()[source]

Placeholder route for calendar synchronization.

Returns:

Redirects to index with a ‘coming soon’ message.

Return type:

redirect

app.routes.toggle_item_tag(course_id, item_id)[source]

Toggles a tag on a specific stream item (assignment).

Parameters:
  • course_id (str) – The Google Course ID.

  • item_id (str) – The Google Item ID (assignment ID).

Returns:

Redirects back to the course stream.

Return type:

redirect

app.routes.toggle_mute_assignment(item_id)[source]

Toggles the muted state of an assignment (hides/shows it in Missing Assignments).

Parameters:

item_id (str) – The Google Item ID.

Returns:

JSON status if AJAX request. redirect: Redirects to missing assignments page if standard request.

Return type:

dict

app.routes.update_course_order()[source]

Updates the display order of courses based on drag-and-drop input.

Expects a JSON payload with an ‘order’ list containing Google Course IDs.

Returns:

Status dictionary {‘status’: ‘success’}.

Return type:

dict

Module contents

The app package initializes the Flask application, database, and login manager. It also sets up configuration and imports routes and models.