manager module#
- exception manager.ExternalCalendarAlreadyExistsError[source]#
Bases:
ExceptionException 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)[source]#
Bases:
objectThe 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[source]#
Checks if a given code exists in the database for a given project id
- get_classrooms(project_id: Optional[str] = None, search_dict: Optional[Dict[str, str]] = None, return_json: bool = False)[source]#
- get_course_resources(project_id: Optional[str] = None) pandas.core.frame.DataFrame[source]#
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][source]#
Returns the courses with given codes as a list. Order of courses is consistent with initial order of the codes.
- get_default_project_id() str[source]#
Returns the default project id.
- Returns
the default project id
- Return type
- get_events_in_classroom(classroom_id: str, project_id: Optional[str] = None) List[backend.events.AcademicalEvent][source]#
- get_plots() List[Tuple[str, dict]][source]#
Returns all the (key, plot) pairs stored in the server. Plots are json dictionary generated using Plotly.
- get_project_ids(year: Optional[str] = None) Optional[Union[List[Dict[str, str]], str]][source]#
Returns the project ids. If year is specified, only the project id of this year is returned.
- get_resource_ids(*codes: str, project_id: Optional[str] = None) Iterator[str][source]#
Returns the resource ids of each code.
- get_resources(project_id: Optional[str] = None) pandas.core.frame.DataFrame[source]#
Returns the resources.
- Parameters
project_id (str) – the project id
- Returns
the resources
- Return type
pd.DataFrame
- save_ics_url(code: str, name: str, url: str, description: str, user: backend.models.User, approved: bool)[source]#
- save_schedule(user: backend.models.User, schedule: backend.schedules.Schedule, uuid)[source]#
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'])[source]#
Updates the classrooms contained in the server for all project ids.
- update_course_resources()[source]#
Updates the course resources contained in the server for all project ids.