Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Volunteer for a slot As a student that wants to volunteer their time in the coding clinic, I want to indicate my availability for a

Volunteer for a slot
As a student that wants to volunteer their time in the coding clinic, I want to indicate my availability for a specific slot.
Do not allow double booking for volunteers
The booking should also show on the volunteers personal Google Calendar
The data file for the volunteer should be updated as well
def create_event():
service = get_calendar_service()
title = input("Add a title: ")
location = input("Add rooms or location: ")
description = input("Add description: ")
timezone = input("Your timezone (e.g., Africa/Johannesburg): ")
# Convert date and time inputs to datetime objects
date_input = input("Enter the date of the event (YYYY-MM-DD): ")
start_time_input = get_valid_time_input("Enter the start time of the event (HH:MM): ")
end_time_input = get_valid_time_input("Enter the end time of the event (HH:MM): ")
start_datetime = datetime.strptime(date_input +""+ start_time_input.strftime("%H:%M"),"%Y-%m-%d %H:%M")
end_datetime = datetime.strptime(date_input +""+ end_time_input.strftime("%H:%M"),"%Y-%m-%d %H:%M")
# Check for double booking
if check_double_booking(start_datetime, end_datetime):
print("Double booking detected, creating the event in a different time slot.")
new_start_time = start_datetime + timedelta(hours=1) # Move the event by 1 hour
new_end_time = new_start_time + timedelta(minutes=30) # Event duration is 30 minutes
else:
print("No double booking detected, creating the event in the specified time slot.")
new_start_time = start_datetime
new_end_time = end_datetime
event ={
"summary": title,
"location": location,
"description": description,
"start": {
"dateTime": new_start_time.isoformat(),
"timeZone": timezone,
},
"end": {
"dateTime": new_end_time.isoformat(),
"timeZone": timezone,
},
"attendees": [],
"reminders": {"useDefault": False, "overrides": []},
}
event = service.events().insert(calendarId='primary', body=event).execute()
print(f'Event created: {event.get("htmlLink")}')
create_event()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions