diff --git a/app/main/routes.py b/app/main/routes.py index 805bcc4..18281e5 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -3,7 +3,7 @@ from flask_login import login_required, current_user from . import bp -from app.models import Agent, Project, Service, Capacity, Period, db +from app.models import Agent, Project, Service, Capacity, Period, db, Company, AgentGrade, AgentStatus, AgentBap from app import db_mgr from app.auth.routes import role_required @@ -121,13 +121,21 @@ def agent_edit(agent_id=None): # Make the form, filled with existing agent if updating # if request.method == 'GET': + companies = Company.query.all() + grades = AgentGrade.query.all() + statuses = AgentStatus.query.all() + baps = AgentBap.query.all() if agent_id: this_agent = Agent.query.get(int(agent_id)) else: this_agent = Agent() # export to structure for jinja display agent_struct = this_agent.to_struct() - return render_template('agent_edit.html', agent=agent_struct) + return render_template('agent_edit.html', agent=agent_struct, + companies=companies, + statuses=statuses, + baps=baps, + grades=grades) # Or submit for db writing # elif request.method == 'POST': @@ -145,7 +153,7 @@ def agent_edit(agent_id=None): db.session.add(this_agent) db.session.commit() # we're done - flash(f"Agent {this_agent.fullname} "+done_string) + flash(f"Agent {this_agent.fullname} " + done_string) return redirect(url_for('main.agent', agent_id=this_agent.id)) diff --git a/app/main/templates/agent.html b/app/main/templates/agent.html index 362e9ad..52c4354 100644 --- a/app/main/templates/agent.html +++ b/app/main/templates/agent.html @@ -33,6 +33,8 @@