Improve on the template, most things work???
This commit is contained in:
parent
c0f9876184
commit
46fa0d1ae5
19 changed files with 396 additions and 181 deletions
9
app/routes/__init__.py
Normal file
9
app/routes/__init__.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from flask import Blueprint
|
||||
|
||||
customer_bp = Blueprint('customer', __name__)
|
||||
technician_bp = Blueprint('technician', __name__)
|
||||
admin_bp = Blueprint('admin', __name__)
|
||||
|
||||
from .customer import *
|
||||
from .technician import *
|
||||
from .admin import *
|
||||
54
app/routes/admin.py
Normal file
54
app/routes/admin.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
from flask import Blueprint, render_template, request, redirect, url_for, flash
|
||||
from app.forms import UserForm, RepairBayForm
|
||||
from app.models import User, RepairBay
|
||||
from app import db
|
||||
|
||||
admin_bp = Blueprint('admin', __name__)
|
||||
|
||||
@admin_bp.route('/admin/dashboard', methods=['GET', 'POST'])
|
||||
def dashboard():
|
||||
if request.method == 'POST':
|
||||
# Handle form submission for creating/removing users or repair bays
|
||||
pass # Implementation will go here
|
||||
|
||||
users = User.query.all()
|
||||
repair_bays = RepairBay.query.all()
|
||||
return render_template('admin/dashboard.html', users=users, repair_bays=repair_bays)
|
||||
|
||||
@admin_bp.route('/admin/user/create', methods=['GET', 'POST'])
|
||||
def create_user():
|
||||
form = UserForm()
|
||||
if form.validate_on_submit():
|
||||
new_user = User(username=form.username.data, email=form.email.data)
|
||||
db.session.add(new_user)
|
||||
db.session.commit()
|
||||
flash('User created successfully!', 'success')
|
||||
return redirect(url_for('admin.dashboard'))
|
||||
return render_template('admin/create_user.html', form=form)
|
||||
|
||||
@admin_bp.route('/admin/user/delete/<int:user_id>', methods=['POST'])
|
||||
def delete_user(user_id):
|
||||
user = User.query.get_or_404(user_id)
|
||||
db.session.delete(user)
|
||||
db.session.commit()
|
||||
flash('User deleted successfully!', 'success')
|
||||
return redirect(url_for('admin.dashboard'))
|
||||
|
||||
@admin_bp.route('/admin/repair_bay/create', methods=['GET', 'POST'])
|
||||
def create_repair_bay():
|
||||
form = RepairBayForm()
|
||||
if form.validate_on_submit():
|
||||
new_bay = RepairBay(name=form.name.data)
|
||||
db.session.add(new_bay)
|
||||
db.session.commit()
|
||||
flash('Repair bay created successfully!', 'success')
|
||||
return redirect(url_for('admin.dashboard'))
|
||||
return render_template('admin/create_repair_bay.html', form=form)
|
||||
|
||||
@admin_bp.route('/admin/repair_bay/delete/<int:bay_id>', methods=['POST'])
|
||||
def delete_repair_bay(bay_id):
|
||||
bay = RepairBay.query.get_or_404(bay_id)
|
||||
db.session.delete(bay)
|
||||
db.session.commit()
|
||||
flash('Repair bay deleted successfully!', 'success')
|
||||
return redirect(url_for('admin.dashboard'))
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
from flask import Blueprint, render_template
|
||||
from flask_login import login_required
|
||||
from app.models import AuditLog
|
||||
|
||||
audit_bp = Blueprint('audit', __name__, url_prefix='/audit')
|
||||
|
||||
@audit_bp.route('/log')
|
||||
@login_required
|
||||
def log():
|
||||
logs = AuditLog.query.order_by(AuditLog.timestamp.desc()).all()
|
||||
return render_template('audit/log.html', logs=logs)
|
||||
|
|
@ -1,11 +1,34 @@
|
|||
from flask import Blueprint, render_template
|
||||
from flask_login import login_required, current_user
|
||||
from app.models import Customer
|
||||
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__, url_prefix='/customers')
|
||||
customer_bp = Blueprint('customer', __name__)
|
||||
|
||||
@customer_bp.route('/portal')
|
||||
@login_required
|
||||
def portal():
|
||||
customer = Customer.query.filter_by(user_id=current_user.id).first_or_404()
|
||||
return render_template('customers/portal.html', customer=customer)
|
||||
@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)
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
from flask import Blueprint, render_template, request, redirect, url_for, flash, current_app
|
||||
from flask_login import login_required, current_user
|
||||
from app.models import db, RepairJob, Customer, Technician, AuditLog
|
||||
from app.utils.barcode import generate_barcode
|
||||
|
||||
repair_bp = Blueprint('repair', __name__, url_prefix='/repairs')
|
||||
|
||||
@repair_bp.route('/new', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def new_repair():
|
||||
if request.method == 'POST':
|
||||
# ... get form data ...
|
||||
repair = RepairJob(
|
||||
device=request.form['device'],
|
||||
description=request.form['description'],
|
||||
customer_id=request.form['customer_id'],
|
||||
technician_id=request.form.get('technician_id'),
|
||||
)
|
||||
db.session.add(repair)
|
||||
db.session.commit()
|
||||
# Generate and save barcode image
|
||||
barcode_path = generate_barcode(repair.id, repair.tracking_number)
|
||||
repair.barcode_path = barcode_path
|
||||
db.session.commit()
|
||||
# Audit log
|
||||
audit = AuditLog(user_id=current_user.id, action='Created repair', details=f"Repair ID {repair.id}")
|
||||
db.session.add(audit)
|
||||
db.session.commit()
|
||||
flash('Repair job created!')
|
||||
return redirect(url_for('repair.detail', repair_id=repair.id))
|
||||
# ... render form ...
|
||||
return render_template('repairs/new.html')
|
||||
|
||||
@repair_bp.route('/<int:repair_id>')
|
||||
@login_required
|
||||
def detail(repair_id):
|
||||
repair = RepairJob.query.get_or_404(repair_id)
|
||||
return render_template('repairs/detail.html', repair=repair)
|
||||
24
app/routes/technician.py
Normal file
24
app/routes/technician.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from flask import Blueprint, render_template, request, redirect, url_for, flash
|
||||
from app.models import Repair, Technician
|
||||
from app.forms import RepairNoteForm
|
||||
|
||||
technician_bp = Blueprint('technician', __name__)
|
||||
|
||||
@technician_bp.route('/technician/dashboard')
|
||||
def dashboard():
|
||||
repairs = Repair.query.filter_by(status='in_progress').all()
|
||||
return render_template('technician/dashboard.html', repairs=repairs)
|
||||
|
||||
@technician_bp.route('/technician/repair/<int:repair_id>', methods=['GET', 'POST'])
|
||||
def repair_detail(repair_id):
|
||||
repair = Repair.query.get_or_404(repair_id)
|
||||
form = RepairNoteForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
repair.notes = form.notes.data
|
||||
repair.status = 'completed'
|
||||
# Add logic to save the repair status and notes
|
||||
flash('Repair notes updated successfully!', 'success')
|
||||
return redirect(url_for('technician.dashboard'))
|
||||
|
||||
return render_template('technician/repair_detail.html', repair=repair, form=form)
|
||||
Loading…
Add table
Add a link
Reference in a new issue