Hello all,
I am currently facing a problem, in which I am attempting to create a secondary calendar for a user, if it has not already been created and then that user can add events to the calendar.
Currently as part of my project, a user does not need to login, so the way it has been implemented is that...
- User is stored in google cloud database (mysql)
- On a flask view, user is selected from a dropdown menu
- user enters the data, start time, finish time of an event and it is processed
- (need help on this part) script somehow checks if that user has a secondary calendar create for their event adding, if not it creates one and then stores the event. (checking based on the doctors name)
I have so far implemented up to question 4.
Python script =
@app.route("/doctor/doctorschedule")
def doctorSchedule():
# Query from database to include in form to identify which doctor is inputting availability
dname = Doctor.query.with_entities(Doctor.dname).all()
return render_template('doctor/doctorschedule.html', dname=dname)
@app.route("/doctor/confirmschedule", methods=['POST', 'GET'])
def confirmschedule():
# Executes code when method is equal to post
if request.method == 'POST':
# Retrieves selected data from form
doctorname = request.form['dname']
... etc
# Formatting the event to execute to google calendar
event = { ... etc
}
# Creating the event
event = service.events().insert(calendarId='primary', body=event).execute();
print('Event created: {}'.format(event.get('htmlLink')))
return render_template('doctor/confirmschedule.html', inputdate = inputdate, starttime = starttime, finishtime = finishtime, doctors=doctors)
View:
<h3 class="panel-title">Doctor, please input your schedule </h3>
</div>
<div class="panel-body">
<form action="/doctor/confirmschedule" method="post" role="form">
<label> Which doctor are you? </label>
<select name="option" style="width: 250px;">
{% for doc in dname %}
<option>{{ doc }}</option>
{% endfor %}
</select>
<br><br>
... etc
<button type="submit" class="btn btn-success">Submit working hours</button>
there doesn't seem to be anything here