mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
gunicorn settings
This commit is contained in:
parent
527e7fd973
commit
1ac8035e7b
6 changed files with 63 additions and 132 deletions
|
|
@ -1 +1 @@
|
||||||
{"access_token": "ya29.Il-0B4bh7Yq32B8mvoTT0EiAbYtzr1snXN_AwfcJzzaXu_L74OpPkkH7UgxQIzh3ZkiF_7fQq5VwZ5lIPE8ag5iei_D58rDeFdvT6x3V0MC9uOAyTBsejAlh2aJl9hY1Lg", "client_id": "1068382961407-1dudhnc4e9d7ham53nr6b7ak3c4dlvme.apps.googleusercontent.com", "client_secret": "F9zmMyRRiTUEAMfRiv8A2l1d", "refresh_token": "1//09MUSHKoeusLDCgYIARAAGAkSNwF-L9IrNOqe0TCFB9n1MZZwuAQNtfkdXAv7x4bUs2AxMwfmTdccxSMhCMEwjaXRUD2WR_EXiss", "token_expiry": "2019-12-06T16:13:57Z", "token_uri": "https://accounts.google.com/o/oauth2/token", "user_agent": null, "revoke_uri": "https://oauth2.googleapis.com/revoke", "id_token": null, "id_token_jwt": null, "token_response": {"access_token": "ya29.Il-0B4bh7Yq32B8mvoTT0EiAbYtzr1snXN_AwfcJzzaXu_L74OpPkkH7UgxQIzh3ZkiF_7fQq5VwZ5lIPE8ag5iei_D58rDeFdvT6x3V0MC9uOAyTBsejAlh2aJl9hY1Lg", "expires_in": 3600, "scope": "https://www.googleapis.com/auth/calendar.readonly", "token_type": "Bearer"}, "scopes": ["https://www.googleapis.com/auth/calendar.readonly"], "token_info_uri": "https://oauth2.googleapis.com/tokeninfo", "invalid": false, "_class": "OAuth2Credentials", "_module": "oauth2client.client"}
|
{"access_token": "ya29.ImC0B6ng8TnZGvS8827TxVZaXax0x25yIjByPGbhAU0piqYLlJMT3w0L3-0Ppz7C9pppOtxS_08ThpN32dqFJUuXKlpftdesbBiohBv9ca7txw3vAisLKAr1-0rW6Yx_ZbU", "client_id": "1068382961407-1dudhnc4e9d7ham53nr6b7ak3c4dlvme.apps.googleusercontent.com", "client_secret": "F9zmMyRRiTUEAMfRiv8A2l1d", "refresh_token": "1//09MUSHKoeusLDCgYIARAAGAkSNwF-L9IrNOqe0TCFB9n1MZZwuAQNtfkdXAv7x4bUs2AxMwfmTdccxSMhCMEwjaXRUD2WR_EXiss", "token_expiry": "2019-12-07T12:37:31Z", "token_uri": "https://accounts.google.com/o/oauth2/token", "user_agent": null, "revoke_uri": "https://oauth2.googleapis.com/revoke", "id_token": null, "id_token_jwt": null, "token_response": {"access_token": "ya29.ImC0B6ng8TnZGvS8827TxVZaXax0x25yIjByPGbhAU0piqYLlJMT3w0L3-0Ppz7C9pppOtxS_08ThpN32dqFJUuXKlpftdesbBiohBv9ca7txw3vAisLKAr1-0rW6Yx_ZbU", "expires_in": 3600, "scope": "https://www.googleapis.com/auth/calendar.readonly", "token_type": "Bearer"}, "scopes": ["https://www.googleapis.com/auth/calendar.readonly"], "token_info_uri": "https://oauth2.googleapis.com/tokeninfo", "invalid": false, "_class": "OAuth2Credentials", "_module": "oauth2client.client"}
|
||||||
|
|
@ -5,8 +5,8 @@ services:
|
||||||
image: postgres
|
image: postgres
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
command: bash -c "python manage.py runserver 0.0.0.0:8000"
|
command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py loaddata villafleurie.json && python manage.py runserver 0.0.0.0:8000"
|
||||||
# command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py loaddata villafleurie.json && gunicorn villafleurie.wsgi 0.0.0.0:8000"
|
# command: gunicorn villafleurie.wsgi -b 0.0.0.0:8000 # Production server more secure
|
||||||
container_name: villafleurie
|
container_name: villafleurie
|
||||||
volumes:
|
volumes:
|
||||||
- .:/villafleurie
|
- .:/villafleurie
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
from __future__ import print_function
|
|
||||||
from googleapiclient import sample_tools
|
|
||||||
from google.auth.transport.requests import Request
|
|
||||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
|
||||||
from googleapiclient.discovery import build
|
|
||||||
import os.path
|
|
||||||
import pickle
|
|
||||||
import datetime
|
|
||||||
from oauth2client import client
|
|
||||||
import sys
|
import sys
|
||||||
|
from googleapiclient import sample_tools
|
||||||
|
import datetime
|
||||||
|
# from __future__ import print_function
|
||||||
|
|
||||||
|
# from google.auth.transport.requests import Request
|
||||||
|
# from google_auth_oauthlib.flow import InstalledAppFlow
|
||||||
|
# from googleapiclient.discovery import build
|
||||||
|
# import os.path
|
||||||
|
# import pickle
|
||||||
|
|
||||||
|
# from oauth2client import client
|
||||||
|
|
||||||
# from rental.models import Reservation
|
# from rental.models import Reservation
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,109 +33,44 @@ def check_availability(place, start_date, end_date):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
"""Simple command-line sample for the Calendar API.
|
|
||||||
Command-line application that retrieves the list of the user's calendars."""
|
|
||||||
|
|
||||||
|
|
||||||
def main1(argv):
|
def main1(argv):
|
||||||
# Authenticate and construct service.
|
"""
|
||||||
|
Simple command-line sample for the Calendar API.
|
||||||
|
Command-line application that retrieves the list of the user's calendars."""
|
||||||
service, _ = sample_tools.init(
|
service, _ = sample_tools.init(
|
||||||
argv, 'calendar', 'v3', __doc__, __file__,
|
argv, 'calendar', 'v3', __doc__, __file__,
|
||||||
scope='https://www.googleapis.com/auth/calendar.readonly')
|
scope='https://www.googleapis.com/auth/calendar.readonly')
|
||||||
|
|
||||||
try:
|
calendars = {
|
||||||
page_token = None
|
'T2': "burik7aclvhc7vsboh06c179uo@group.calendar.google.com",
|
||||||
while True:
|
'T3': "fu7h30p0gk4a2p4nvo7nsbgpok@group.calendar.google.com"
|
||||||
calendar_list = service.calendarList().list(
|
}
|
||||||
pageToken=page_token).execute()
|
|
||||||
for calendar_list_entry in calendar_list['items']:
|
|
||||||
print(calendar_list_entry['summary'])
|
|
||||||
page_token = calendar_list.get('nextPageToken')
|
|
||||||
|
|
||||||
if not page_token:
|
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
|
||||||
break
|
|
||||||
|
|
||||||
# Call the Calendar API
|
for calendar in calendars:
|
||||||
calendar_list = service.calendarList().list(
|
print(f"Upcoming {calendar} events:")
|
||||||
pageToken=page_token).execute()
|
events_result = service.events().list(
|
||||||
# print(calendar_list)
|
calendarId=calendars[calendar],
|
||||||
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
|
timeMin=now,
|
||||||
print('Getting the upcoming 10 T2 arrivals')
|
maxResults=10, singleEvents=True,
|
||||||
|
orderBy='startTime').execute()
|
||||||
events_result = service.events().list(calendarId='burik7aclvhc7vsboh06c179uo@group.calendar.google.com', timeMin=now,
|
|
||||||
maxResults=10, singleEvents=True,
|
|
||||||
orderBy='startTime').execute()
|
|
||||||
events = events_result.get('items', [])
|
events = events_result.get('items', [])
|
||||||
|
reservation = {}
|
||||||
if not events:
|
if not events:
|
||||||
print('No upcoming events found.')
|
print('No upcoming events found.')
|
||||||
for event in events:
|
for index, event in enumerate(events):
|
||||||
start = event['start'].get('dateTime', event['start'].get('date'))
|
# start = event['start'].get('dateTime', event['start'].get('date'))
|
||||||
end = event['end'].get('dateTime', event['end'].get('date'))
|
# end = event['end'].get('dateTime', event['end'].get('date'))
|
||||||
print(start, end, event['summary'])
|
# print(start, end, event['summary'])
|
||||||
|
reservation[index] = {
|
||||||
print('Getting the upcoming 10 T3 arrivals')
|
'place': calendar,
|
||||||
events_result = service.events().list(calendarId='fu7h30p0gk4a2p4nvo7nsbgpok@group.calendar.google.com', timeMin=now,
|
'guest': event['summary'],
|
||||||
maxResults=10, singleEvents=True,
|
'start': event['start'].get('dateTime', event['start'].get('date')),
|
||||||
orderBy='startTime').execute()
|
'end': event['end'].get('dateTime', event['end'].get('date'))
|
||||||
events = events_result.get('items', [])
|
}
|
||||||
|
print(reservation[index])
|
||||||
if not events:
|
|
||||||
print('No upcoming events found.')
|
|
||||||
for event in events:
|
|
||||||
start = event['start'].get('dateTime', event['start'].get('date'))
|
|
||||||
end = event['end'].get('dateTime', event['end'].get('date'))
|
|
||||||
print(start, end, event['summary'])
|
|
||||||
|
|
||||||
except client.AccessTokenRefreshError:
|
|
||||||
print('The credentials have been revoked or expired, please re-run'
|
|
||||||
'the application to re-authorize.')
|
|
||||||
|
|
||||||
|
|
||||||
# If modifying these scopes, delete the file token.pickle.
|
|
||||||
# SCOPES = ['https://www.googleapis.com/auth/calendar.readonly']
|
|
||||||
|
|
||||||
|
|
||||||
# def main():
|
|
||||||
# """Shows basic usage of the Google Calendar API.
|
|
||||||
# Prints the start and name of the next 10 events on the user's calendar.
|
|
||||||
# """
|
|
||||||
# creds = None
|
|
||||||
# # The file token.pickle stores the user's access and refresh tokens, and is
|
|
||||||
# # created automatically when the authorization flow completes for the first
|
|
||||||
# # time.
|
|
||||||
# if os.path.exists('token.pickle'):
|
|
||||||
# with open('token.pickle', 'rb') as token:
|
|
||||||
# creds = pickle.load(token)
|
|
||||||
# # If there are no (valid) credentials available, let the user log in.
|
|
||||||
# if not creds or not creds.valid:
|
|
||||||
# if creds and creds.expired and creds.refresh_token:
|
|
||||||
# creds.refresh(Request())
|
|
||||||
# else:
|
|
||||||
# flow = InstalledAppFlow.from_client_secrets_file(
|
|
||||||
# 'credentials.json', SCOPES)
|
|
||||||
# creds = flow.run_local_server(port=0)
|
|
||||||
# # Save the credentials for the next run
|
|
||||||
# with open('token.pickle', 'wb') as token:
|
|
||||||
# pickle.dump(creds, token)
|
|
||||||
|
|
||||||
# service = build('calendar', 'v3', credentials=creds)
|
|
||||||
|
|
||||||
# # Call the Calendar API
|
|
||||||
# now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
|
|
||||||
# print('Getting the upcoming 10 events')
|
|
||||||
# events_result = service.events().list(calendarId='primary', timeMin=now,
|
|
||||||
# maxResults=10, singleEvents=True,
|
|
||||||
# orderBy='startTime').execute()
|
|
||||||
# events = events_result.get('items', [])
|
|
||||||
|
|
||||||
# if not events:
|
|
||||||
# print('No upcoming events found.')
|
|
||||||
# for event in events:
|
|
||||||
# start = event['start'].get('dateTime', event['start'].get('date'))
|
|
||||||
# print(start, event['summary'])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main1(sys.argv)
|
main1(sys.argv)
|
||||||
# main()
|
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ def calendar(request, place_name):
|
||||||
booked_dates = Reservation.objects.all()
|
booked_dates = Reservation.objects.all()
|
||||||
bookings = [
|
bookings = [
|
||||||
booking for booking in booked_dates if booking.place.name == place_name]
|
booking for booking in booked_dates if booking.place.name == place_name]
|
||||||
print(place_name)
|
# print(place_name)
|
||||||
context = {
|
context = {
|
||||||
'place_name': place_name,
|
'place_name': place_name,
|
||||||
'bookings': bookings
|
'bookings': bookings
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
asgiref==3.2.3
|
asgiref==3.2.3
|
||||||
dj-database-url==0.5.0
|
dj-database-url==0.5.0
|
||||||
Django==3.0
|
Django==3.0
|
||||||
|
google-api-python-client==1.7.11
|
||||||
Pillow==6.2.1
|
Pillow==6.2.1
|
||||||
psycopg2==2.8.4
|
psycopg2==2.8.4
|
||||||
pytz==2019.3
|
pytz==2019.3
|
||||||
|
|
|
||||||
|
|
@ -65,29 +65,29 @@ TEMPLATES = [
|
||||||
|
|
||||||
WSGI_APPLICATION = 'villafleurie.wsgi.application'
|
WSGI_APPLICATION = 'villafleurie.wsgi.application'
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
|
||||||
'NAME': 'villafleurie',
|
|
||||||
'USER': 'nemausat',
|
|
||||||
'PASSWORD': '',
|
|
||||||
'HOST': '',
|
|
||||||
'PORT': '5432',
|
|
||||||
'ATOMIC_REQUESTS': True
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# DATABASES = {
|
# DATABASES = {
|
||||||
# 'default': {
|
# 'default': {
|
||||||
# 'ENGINE': 'django.db.backends.postgresql',
|
# 'ENGINE': 'django.db.backends.postgresql',
|
||||||
# 'NAME': 'postgres',
|
# 'NAME': 'villafleurie',
|
||||||
# 'USER': 'postgres',
|
# 'USER': 'nemausat',
|
||||||
# 'HOST': 'db',
|
# 'PASSWORD': '',
|
||||||
|
# 'HOST': '',
|
||||||
# 'PORT': '5432',
|
# 'PORT': '5432',
|
||||||
# 'ATOMIC_REQUESTS': True
|
# 'ATOMIC_REQUESTS': True
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'NAME': 'postgres',
|
||||||
|
'USER': 'postgres',
|
||||||
|
'HOST': 'db',
|
||||||
|
'PORT': '5432',
|
||||||
|
'ATOMIC_REQUESTS': True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if os.environ.get('ENV') == 'PRODUCTION':
|
if os.environ.get('ENV') == 'PRODUCTION':
|
||||||
# Heroku
|
# Heroku
|
||||||
db_from_env = dj_database_url.config(conn_max_age=500)
|
db_from_env = dj_database_url.config(conn_max_age=500)
|
||||||
|
|
@ -106,18 +106,10 @@ if os.environ.get('ENV') == 'PRODUCTION':
|
||||||
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', },
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', },
|
||||||
},
|
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', },
|
||||||
{
|
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', },
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
LANGUAGE_CODE = 'fr'
|
LANGUAGE_CODE = 'fr'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue