doc: update comments

This commit is contained in:
Ruidy Nemausat 2020-07-31 13:44:51 +02:00
parent 865f93866e
commit a13adb7bc4
2 changed files with 16 additions and 31 deletions

View file

@ -15,7 +15,9 @@ from villafleurie.settings import BASE_DIR
def build_service(): def build_service():
""" Build Google Calendar API service and returns calendar list and service """ """
Build Google Calendar API service and returns calendar list and service
"""
creds = None creds = None
@ -75,9 +77,11 @@ def get_bookings(place):
def synchronize(place): def synchronize(place):
""" Get a complete list of existing bookings in calendar """
Get a complete list of existing bookings in calendar
Creates reservation if not in db, update if already in db Creates reservation if not in db, update if already in db
Delete from db reservation deleted from cal """ Delete from db reservation deleted from cal
"""
reservation = get_bookings(place) reservation = get_bookings(place)
if not reservation: if not reservation:
@ -110,10 +114,11 @@ def synchronize(place):
db_booking.end = end db_booking.end = end
def get_bookings_from_db(place): def get_bookings_from_db(place):
""" Synchronize with Master calendar via a call to synchronize_calendar """
Returns a list of all related place reservations """ Synchronize with Master calendar via a call to synchronize_calendar
Returns a list of all related place reservations
"""
synchronize(place) synchronize(place)
booked_dates = m_booking.Booking.objects.filter(place=place) booked_dates = m_booking.Booking.objects.filter(place=place)
@ -122,7 +127,7 @@ def get_bookings_from_db(place):
def check_availability(place, start_date, end_date): def check_availability(place, start_date, end_date):
""" check if the related place is available during a given period """ """Checks if the related place is available during a given period."""
bookings = get_bookings_from_db(place) bookings = get_bookings_from_db(place)
for booking in bookings: for booking in bookings:
@ -133,7 +138,7 @@ def check_availability(place, start_date, end_date):
def update(reservation): def update(reservation):
""" push new reservation to master calendar """ """Push new reservation to master calendar."""
# authenticate and build service # authenticate and build service
service, calendars = build_service() service, calendars = build_service()
@ -153,23 +158,3 @@ def update(reservation):
}, },
} }
).execute() ).execute()
if __name__ == '__main__':
s, c = build_service()
from google_auth_oauthlib.flow import Flow
SCOPES = [
'https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.events'
]
SECRETS = '/client_secrets.json'
flow = Flow.from_client_secrets_file(
SECRETS,
scopes=SCOPES,
redirect_uri='http://localhost:8080/'
)

View file

@ -10,8 +10,8 @@
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from datetime import datetime
import os import os
from datetime import datetime
import requests import requests
from celery import shared_task from celery import shared_task