def initialize(): DATABASE.create_tables([User, Saloon, Appointment], safe=True) try: User.create(first_name="Felicia", last_name="Mueni", email="*****@*****.**") except IntegrityError: pass try: Saloon.create(name="Mrembo", business_number="9897", opening_time="10:00 am", closing_time="5:00 pm", description="Urembo services", services="Manicure, Pedicure, Haircare", user_id=1, location="George Padimore Lane") except IntegrityError: pass try: no_appointments = Appointment.select().count() if no_appointments < 1: Appointment.create(user_id=1, saloon_id=1, services="Manicure, Pedicure", time_appointment=datetime.datetime.now()) except IntegrityError: pass
def make_appointment(): appointment_data = dict(request.form.items()) time_appointment_raw = appointment_data.get('time_appointment') time_appointment_processed = datetime.strptime(time_appointment_raw, "%d %b %Y %H:%M") Appointment.create(user_id=appointment_data.get('user_id'), saloon_id=appointment_data.get('saloon_id'), services=appointment_data.get('services'), time_appointment=time_appointment_processed) result = {"status": "Success", "message": "Appointment set"} return jsonify(result)
def initialize(): DATABASE.create_tables( [User, Saloon, Appointment, Register, Service, Saloonservices], safe=True) try: User.create( user_name="feliciah", service="haircare", password="******", ) except IntegrityError: pass try: Service.create(service="manicure", price=1000) except IntegrityError: pass try: Saloon.create(name="mrembo", business_number="9887", opening_time="10:00am", closing_time="5:00pm", description="urembo services", services="manicure,pedicure,haircare", user_id=1, location='location') except IntegrityError: pass try: Register.create(user_name="feliciah", email="*****@*****.**", phone_number="0712343647", service="manicure", password="******", confirm_password="******") except IntegrityError: pass try: Appointment.create(user_id=1, salon_id=1, services="haircare,manicure,facial", time_appointment=datetime.datetime.now()) except IntegrityError: pass DATABASE.close()