def accept_availability_requests(aid, pid): # front-end needs to convert it to UTC ie. 2020-05-01 11:00:00 appointment_date_time = request.form['date-time'] appointment_duration_min = request.form['duration-min'] update_db('UPDATE appointments SET professional_scheduled = CURRENT_TIMESTAMP, appointment_date = ?, ' 'appointment_duration = ? WHERE professional_id = ? AND id = ?', [appointment_date_time, appointment_duration_min, pid,aid]) return {}, status.HTTP_202_ACCEPTED
def update_badge_table(badge_name, badge_description, professionals): # update badge table for p in professionals: # update badge table update_db('INSERT INTO badges (badge_name, badge_description, professional_id) VALUES (?, ?, ?)',[badge_name, badge_description, p["professional_id"]]) # update the search profile # this will add the same badge to the profile many time - this is ok for the beginning update_db('UPDATE profile_search SET profile = ? || \' \' || profile WHERE professional_id = ?', [badge_name, p["professional_id"]])
def update_bookmarks(id, professional_id): maybe_bookmark = query_db('SELECT professional_id FROM professionals_bookmarks WHERE consumer_id = ? AND ' 'professional_id = ? ', [id, professional_id]) # if bookmark exists remove it, else create it if not maybe_bookmark: r = update_db('INSERT INTO professionals_bookmarks (consumer_id, professional_id) values (?, ?)', [id, professional_id]) return {}, status.HTTP_202_ACCEPTED else: update_db('DELETE FROM professionals_bookmarks WHERE consumer_id = ? AND professional_id = ?', [id, professional_id]) return {}, status.HTTP_202_ACCEPTED
def decline_availability_requests(aid, pid): update_db( 'UPDATE appointments SET professional_declined = CURRENT_TIMESTAMP WHERE professional_id = ? AND id = ?', [pid, aid]) return {}, status.HTTP_202_ACCEPTED
def resign_availability(aid, pid, cid): update_db( 'UPDATE appointments SET consumer_resigned = CURRENT_TIMESTAMP WHERE professional_id = ? AND ' 'consumer_id = ? AND id = ?', [pid, cid, aid]) return {}, status.HTTP_202_ACCEPTED
def request_availability(pid, cid): id = update_db( 'INSERT INTO appointments (professional_id, consumer_id) values (?, ?)', [pid, cid]) return {"id": id}, status.HTTP_201_CREATED
from os import environ from flask import Flask from app.config import DefaultConfig, DevelopementConfig, TestConfig app = Flask('eifelstats') if environ.get('EIFELSTATS_CTX') is None: app.config.from_object(DefaultConfig) elif environ.get('EIFELSTATS_CTX') == 'developement': app.config.from_object(DevelopementConfig) elif environ.get('EIFELSTATS_CTX') == 'test': app.config.from_object(TestConfig) from app.api import api from app.db import update_db, init_db update_db()