OpenSTR/app/routes/customer.py

34 lines
No EOL
1.5 KiB
Python

from flask import Blueprint, render_template, request, redirect, url_for, flash
from app.forms import AppointmentForm
from app.models import Appointment, Repair, Customer
customer_bp = Blueprint('customer', __name__)
@customer_bp.route('/dashboard')
def dashboard():
# Logic to retrieve customer data, repairs, and appointments
customer_id = 1 # Placeholder for actual customer ID retrieval
repairs = Repair.query.filter_by(customer_id=customer_id).all()
appointments = Appointment.query.filter_by(customer_id=customer_id).all()
customer = Customer.query.filter_by(customer_id=customer_id).all()
return render_template('customer/dashboard.html', repairs=repairs, appointments=appointments, customer=customer)
@customer_bp.route('/schedule_appointment', methods=['GET', 'POST'])
def schedule_appointment():
form = AppointmentForm()
if form.validate_on_submit():
new_appointment = Appointment(
customer_id=form.customer_id.data,
date=form.date.data,
time=form.time.data,
notes=form.notes.data
)
# Logic to save the appointment to the database
flash('Appointment scheduled successfully!', 'success')
return redirect(url_for('customer.dashboard'))
return render_template('customer/schedule_appointment.html', form=form)
@customer_bp.route('/track_progress/<int:repair_id>')
def track_progress(repair_id):
repair = Repair.query.get_or_404(repair_id)
return render_template('customer/track_progress.html', repair=repair)