mirror of
https://github.com/rjNemo/villafleurie
synced 2026-06-12 13:26:47 +00:00
updates
This commit is contained in:
parent
1ac8035e7b
commit
9507b80868
5 changed files with 49 additions and 30 deletions
|
|
@ -1 +1 @@
|
||||||
{"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"}
|
{"access_token": "ya29.ImC0B0Q3_uq2vb5v7pQGku3BceBHt0nb6lseQUvA8Tp3tgdK0_poDnAGPEGGcSc3pKc_ljRSKCGOG3nq8srlOofPUHyBVfKj_5AB8bJYdny0wKPfQ_LdxU-JOXT1_yxxHhQ", "client_id": "1068382961407-1dudhnc4e9d7ham53nr6b7ak3c4dlvme.apps.googleusercontent.com", "client_secret": "F9zmMyRRiTUEAMfRiv8A2l1d", "refresh_token": "1//09MUSHKoeusLDCgYIARAAGAkSNwF-L9IrNOqe0TCFB9n1MZZwuAQNtfkdXAv7x4bUs2AxMwfmTdccxSMhCMEwjaXRUD2WR_EXiss", "token_expiry": "2019-12-07T21:59:14Z", "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.ImC0B0Q3_uq2vb5v7pQGku3BceBHt0nb6lseQUvA8Tp3tgdK0_poDnAGPEGGcSc3pKc_ljRSKCGOG3nq8srlOofPUHyBVfKj_5AB8bJYdny0wKPfQ_LdxU-JOXT1_yxxHhQ", "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,7 +5,8 @@ services:
|
||||||
image: postgres
|
image: postgres
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
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 && 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 -b 0.0.0.0:8000"
|
||||||
# command: gunicorn villafleurie.wsgi -b 0.0.0.0:8000 # Production server more secure
|
# command: gunicorn villafleurie.wsgi -b 0.0.0.0:8000 # Production server more secure
|
||||||
container_name: villafleurie
|
container_name: villafleurie
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
import sys
|
import sys
|
||||||
from googleapiclient import sample_tools
|
from googleapiclient import sample_tools
|
||||||
import datetime
|
import datetime
|
||||||
# from __future__ import print_function
|
from rental.pricing import get_reservation_price
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from rental.models import Reservation, Place
|
||||||
|
|
||||||
|
# from __future__ import print_function
|
||||||
# from google.auth.transport.requests import Request
|
# from google.auth.transport.requests import Request
|
||||||
# from google_auth_oauthlib.flow import InstalledAppFlow
|
# from google_auth_oauthlib.flow import InstalledAppFlow
|
||||||
# from googleapiclient.discovery import build
|
# from googleapiclient.discovery import build
|
||||||
# import os.path
|
# import os.path
|
||||||
# import pickle
|
# import pickle
|
||||||
|
|
||||||
# from oauth2client import client
|
# from oauth2client import client
|
||||||
|
|
||||||
# from rental.models import Reservation
|
|
||||||
|
|
||||||
|
|
||||||
def get_bookings(place):
|
def get_bookings(place):
|
||||||
"""
|
"""
|
||||||
|
|
@ -33,10 +33,11 @@ def check_availability(place, start_date, end_date):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def main1(argv):
|
def synchronize_calendars(argv):
|
||||||
"""
|
"""
|
||||||
Simple command-line sample for the Calendar API.
|
Simple command-line sample for the Calendar API.
|
||||||
Command-line application that retrieves the list of the user's calendars."""
|
Command-line application that retrieves the list of calendars' events
|
||||||
|
"""
|
||||||
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')
|
||||||
|
|
@ -53,7 +54,7 @@ def main1(argv):
|
||||||
events_result = service.events().list(
|
events_result = service.events().list(
|
||||||
calendarId=calendars[calendar],
|
calendarId=calendars[calendar],
|
||||||
timeMin=now,
|
timeMin=now,
|
||||||
maxResults=10, singleEvents=True,
|
singleEvents=True,
|
||||||
orderBy='startTime').execute()
|
orderBy='startTime').execute()
|
||||||
events = events_result.get('items', [])
|
events = events_result.get('items', [])
|
||||||
reservation = {}
|
reservation = {}
|
||||||
|
|
@ -70,7 +71,19 @@ def main1(argv):
|
||||||
'end': event['end'].get('dateTime', event['end'].get('date'))
|
'end': event['end'].get('dateTime', event['end'].get('date'))
|
||||||
}
|
}
|
||||||
print(reservation[index])
|
print(reservation[index])
|
||||||
|
place = get_object_or_404(Place, name=calendar)
|
||||||
|
price = get_reservation_price(
|
||||||
|
place, reservation['start'], reservation['end'])
|
||||||
|
guest = Guest.objects.create(name=reservation['guest'])
|
||||||
|
|
||||||
|
Reservation.objects.create(
|
||||||
|
place=place,
|
||||||
|
guest=guest,
|
||||||
|
start=start,
|
||||||
|
end=end,
|
||||||
|
price=price
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main1(sys.argv)
|
synchronize_calendars(sys.argv)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ from django.views.generic.base import TemplateView
|
||||||
from .forms import ReservationForm
|
from .forms import ReservationForm
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
from rental.pricing import get_reservation_price
|
from rental.pricing import get_reservation_price
|
||||||
from rental.bookings import check_availability
|
from rental.bookings import check_availability # , synchronize_calendars
|
||||||
|
# import sys
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
|
|
@ -40,7 +41,6 @@ def location(request, place_name='T2'):
|
||||||
'images': images
|
'images': images
|
||||||
}
|
}
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
# , error_class=ParagraphErrorList)
|
|
||||||
form = ReservationForm(request.POST)
|
form = ReservationForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
name = form.cleaned_data['name']
|
name = form.cleaned_data['name']
|
||||||
|
|
@ -92,7 +92,6 @@ def location(request, place_name='T2'):
|
||||||
|
|
||||||
def reservation(request):
|
def reservation(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
# , error_class=ParagraphErrorList)
|
|
||||||
form = ReservationForm(request.POST)
|
form = ReservationForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
name = form.cleaned_data['name']
|
name = form.cleaned_data['name']
|
||||||
|
|
@ -147,7 +146,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)
|
# synchronize_calendars(sys.argv)
|
||||||
context = {
|
context = {
|
||||||
'place_name': place_name,
|
'place_name': place_name,
|
||||||
'bookings': bookings
|
'bookings': bookings
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,13 @@ if os.environ.get('ENV') == 'PRODUCTION':
|
||||||
else:
|
else:
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', 'villafleurie.herokuapp.com']
|
# DEBUG = False
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = [
|
||||||
|
'127.0.0.1',
|
||||||
|
'localhost',
|
||||||
|
'villafleurie.herokuapp.com'
|
||||||
|
]
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
|
@ -65,29 +71,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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue