Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

app.calendarutil

Seamus Smith edited this page Apr 29, 2022 · 6 revisions

app.calendarutil

Constants

  • CALENDAR_ID_SUFFIX = "ratatoskr.techhigh.us"
    • Suffix for the calendar's id
  • CALENDAR_TIMESLOT_EVENT_ID = "%(timeslot_id)s@%(schedule_id)s#" + CALENDAR_ID_SUFFIX
    • Template string for calendar events for timeslots

Functions

hashify(string: str) -> str

Returns the SHA1 hash of a string in hex form

build_timeslot_event_id(timeslot: TimeSlot) -> str:

Creates an ID to be used for a calendar event for a TimeSlot

build_calendar_client(user: User) -> googleapiclinet.discovery.Resource:

Builds a Google API resource for interacting with the given User's calendar

All functions past this point are executed asynchronously

create_calendar_for_schedule(schedule: Schedule) -> tuple[dict, str]:

Creates a secondary calendar for the owner of the schedule. Also creates a Google Meet that every event in the Calendar will use. This is done by creating a temporary event that asks for a hangoutsMeet to be created and retrieving the conferenceData from the returned resource. The event is then deleted.

Returns a tuple containing:

  • The conferenceData
  • The calendar's ID

delete_calendar_for_schedule(schedule: Schedule) -> None:

Deletes the Calendar associated with the Schedule. This is done asynchronously.

update_timeslot_event(timeslot: TimeSlot, reservation: Reservation | None) -> None

Updates the given timeslot's event with the new reservations. If the event doesn't exist, the event will be created. Has the optional parameter reservation for the case where the Reservation is not committed to the database yet.

delete_timeslot_event(timeslot: TimeSlot) -> None

Deletes the event for the given timeslot.

change_visibility(schedule: Schedule) -> None

Update Google Calendar visibility with schedule visibility.

add_subscriber(schedule: Schedule, user: User) -> None

Shares the provided schedule with the subscriber.

remove_subscriber(schedule: Schedule, user: User) -> None

Removes the user from the provided schedule.

Clone this wiki locally