manager module

exception manager.ExternalCalendarAlreadyExistsError

Bases: Exception

Exception that will occur if someone tries to create a calendar with a code already taken.

class manager.Manager(client: backend.ade_api.Client, server: backend.servers.Server, database: flask_sqlalchemy.SQLAlchemy, ttl: Dict)

Bases: object

The manager ensures that data is accessible and provides access to it.

Data can either be found in the server, in the database or obtained from the ADE API. At initialization, each source is checked to ensure that they are working properly.

Parameters
  • client (ade_api.Client) – the client providing access to ADE API

  • server (server.Server) – the server providing temporary memory

  • database (md.SQLAlchemy) – the database

  • ttl (Dict) – a dictionary mapping keys in server to their default time-to-live value

code_exists(code, project_id: Optional[str] = None) bool

Checks if a given code exists in the database for a given project id

delete_external_calendar(id: int)
get_classrooms(project_id: Optional[str] = None, search_dict: Optional[Dict[str, str]] = None, return_json: bool = False)
get_codes_matching(pattern: str, project_id: Optional[str] = None) List[str]
get_course_resources(project_id: Optional[str] = None) pandas.core.frame.DataFrame

Returns the course resources.

Parameters

project_id (str) – the project id

Returns

the courses resources

Return type

pd.DataFrame

get_courses(*codes: str, project_id: Optional[str] = None) List[backend.courses.Course]

Returns the courses with given codes as a list. Order of courses is consistent with initial order of the codes.

Parameters
  • codes (str) – the code(s) of the course(s)

  • project_id (str) – the project id

Returns

the list of courses

Return type

List[crs.Course]

get_default_project_id() str

Returns the default project id.

Returns

the default project id

Return type

str

get_events_in_classroom(classroom_id: str, project_id: Optional[str] = None) List[backend.events.AcademicalEvent]
get_external_calendars(user: backend.models.User) List[backend.models.ExternalCalendar]
get_plots() List[Tuple[str, dict]]

Returns all the (key, plot) pairs stored in the server. Plots are json dictionary generated using Plotly.

Returns

the pairs of (key, plot) that were stored in the server

Return type

List[Tuple[str, dict]]

get_project_ids(year: Optional[str] = None) Optional[Union[List[Dict[str, str]], str]]

Returns the project ids. If year is specified, only the project id of this year is returned.

Parameters

year (str) – the year, ‘2019-2020’ format

Returns

the list of ids and years or the id of one year or None if no id was found

Return type

Union[List[Dict[str, str]], str, None]

get_resource_ids(*codes: str, project_id: Optional[str] = None) Iterator[str]

Returns the resource ids of each code.

Parameters
  • codes (str) – the code(s) (name(s)) of the resources

  • project_id (str) – the project id

Returns

the resource ids

Return type

Iterator[str]

get_resources(project_id: Optional[str] = None) pandas.core.frame.DataFrame

Returns the resources.

Parameters

project_id (str) – the project id

Returns

the resources

Return type

pd.DataFrame

get_schedule(link)
save_ics_url(code: str, name: str, url: str, description: str, user: backend.models.User, approved: bool)
save_schedule(user: backend.models.User, schedule: backend.schedules.Schedule, uuid)

Saves a schedule binding it to a user into the database.

Parameters
  • user (md.User) – the user

  • schedule (schd.Schedule) – the schedule

Returns

the scheduler, with its id updated…

update_classrooms(drop_empty: List[str] = ['address1'])

Updates the classrooms contained in the server for all project ids.

update_course_resources()

Updates the course resources contained in the server for all project ids.

update_project_ids()

Updates the project ids.

update_resource_ids()

Updates the resource ids contained in the server for all project ids.

update_resources()

Updates the resources contained in the server for all project ids.

exception manager.ScheduleNotFountError

Bases: Exception

Exception that will occur if a schedule is marked as saved but is not in the database.