Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions app/controllers/main_routes/main_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from app.login_manager import require_login, logout
from app.logic.getTableData import getDatatableData
from app.logic.banner import Banner
from app.models.positionHistory import PositionHistory

@main_bp.route('/logout', methods=['GET'])
def triggerLogout():
Expand Down Expand Up @@ -63,26 +64,40 @@ def departmentPortal(org=None,account=None):
else:
departments = list(getDepartmentsForSupervisor(g.currentUser).order_by(Department.isActive.desc(), Department.DEPT_NAME.asc()))

if dept and not g.currentUser.isLaborAdmin and dept.departmentID not in [d.departmentID for d in departments]:
return render_template('errors/403.html'), 403

return render_template('main/departmentPortal.html',
departments = departments,
department = dept)

@main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST'])
def addUserToDept():
userDeptData = request.form
supervisorDeptRecord = SupervisorDepartment.get_or_none(supervisor = userDeptData['supervisorID'], department = userDeptData['departmentID'])
try:
if supervisorDeptRecord:
return "False"
department = dept,
)

else:
SupervisorDepartment.create(supervisor=userDeptData['supervisorID'], department=userDeptData['departmentID'])
return "True"

except Exception as e:
print(f'Could not add user to department: {e}')
return "", 500
@main_bp.route('/department/<org>/<account>/positions', methods=['GET'])
def managePositions(org, account):
currentUser = require_login()
if not currentUser or not currentUser.supervisor:
return render_template('errors/403.html'), 403

try:
dept = Department.get(Department.ORG == org, Department.ACCOUNT == account)
except DoesNotExist:
return render_template('errors/404.html'), 404

if not currentUser.isLaborAdmin:
allowedDepartmentIds = [d.departmentID for d in getDepartmentsForSupervisor(currentUser)]
if dept.departmentID not in allowedDepartmentIds:
return render_template('errors/403.html'), 403

positions = (PositionHistory.select()
.where((PositionHistory.department == dept) &
(PositionHistory.status == "Active"))
.order_by(PositionHistory.positionTitle.asc()))

return render_template('main/managePositions.html',
department = dept,
department_name = dept.DEPT_NAME,
positions = positions
)
@main_bp.route('/supervisorPortal/download', methods=['POST'])
def downloadSupervisorPortalResults():
'''
Expand Down
1 change: 1 addition & 0 deletions app/models/positionHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from app.models.department import Department

class PositionHistory(baseModel):
positionTitle = CharField()
positionCode = CharField()
department = ForeignKeyField(Department)
status = CharField()
Expand Down
33 changes: 33 additions & 0 deletions app/static/css/managePositions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.width-12{
width:12%;
}
.margin-top-10{
margin-top:-25px;
}
*{
/* outline:solid 1px lime; */
margin:0;
padding:0;
box-sizing:border-box;
}

.department-header{
padding:1%;
margin-top:-20px;
}

td{
text-align:center !important;
}/* managePositions.css */

.position-management .width-12 {
width: 12%;
}

.position-management h1 {
margin-top: 10px;
}

.position-management td {
text-align: center;
}
9 changes: 9 additions & 0 deletions app/static/js/managePositions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$(document).ready(function () {
$('#positionTable').DataTable({
pageLength: 25,
columnDefs: [
{ className: 'dt-head-center', targets: '_all' },
{ orderable: false, targets: [4,4 ] }
]
});
});
48 changes: 48 additions & 0 deletions app/templates/main/managePositions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends "base.html" %}

{% block styles %}
{{ super() }}
<link rel="stylesheet" href="https://cdn.datatables.net/v/dt/dt-2.1.6/datatables.min.css">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/managePositions.css') }}?u={{ lastStaticUpdate }}">
{% endblock %}

{% block scripts %}
{{ super() }}
<script src="https://cdn.datatables.net/v/dt/dt-2.1.6/datatables.min.js"></script>
<script src="{{ url_for('static', filename='js/managePositions.js') }}?u={{ lastStaticUpdate }}"></script>
{% endblock %}

{% block app_content %}
<div class="container-fluid position-management">
<h1 class="text-center margin-top-10">{{ department_name }} Positions</h1>

<div class="table-responsive">
<table id="positionTable" class="table table-striped table-bordered text-center">
<thead>
<tr>
<th class="text-center width-12">Position</th>
<th class="text-center width-12">WLS</th>
<th class="text-center width-12">Last Revision Date</th>
<th class="text-center width-12">View Position Description</th>
<th class="text-center width-12">Edit Position Description</th>
</tr>
</thead>
<tbody>
{% for position in positions %}
<tr>
<td>{{ position.positionTitle }} <small class="text-muted">{{ position.positionCode }}</small></td>
<td>{{ position.wls }}</td>
<td>{{ position.revisionDate }}</td>
<td>
<button class="btn btn-success view-btn" data-position-id="{{ position.id }}">View</button>
</td>
<td>
<button class="btn btn-primary request-btn" data-position-id="{{ position.id }}">Edit Position</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
81 changes: 77 additions & 4 deletions database/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,48 +751,121 @@
#############################

positionHistory = [
{
{
"positionTitle": "Student Programmer",
"positionCode": "S61407",
"status": "Active",
"wls": 1,
"revisionDate": f"2025-07-01",
"revisionDate": f"2026-07-01",
"description": "",
"department": 1
},
{

"positionTitle": "Research Associate",
"positionCode": "S61408",
"status": "Active",
"wls": 2,
"revisionDate": f"2025-09-01",
"revisionDate": f"2026-09-01",
"description": "",
"department": 1
},
{
"positionTitle": "Labor Workers",
"positionCode": "S61409",
"status": "Active",
"wls": 3,
"revisionDate": f"2025-07-01",
"revisionDate": f"2026-07-01",
"description": "",
"department": 1
},
{
"positionTitle": "Teaching Associate",
"positionCode": "S61411",
"status": "Active",
"wls":3,
"revisionDate" : f"2025-01-01",
"revisionDate" : f"2026-01-01",
"description": "",
"department" : 1

},
{
},
{
"positionTitle": "Teaching Associate",
"positionCode": "S61410",
"status": "Inactive",
"wls":2,
"revisionDate" : f"2025-01-01",
"revisionDate" : f"2026-01-01",
"description": "",
"department" : 3
},
{
"positionTitle": "Teaching Associate",
"positionCode": "S61410",
"status": "Active",
"wls":2,
"revisionDate" : f"2026-03-29",
"description": "",
"department" : 3
},
{
"positionTitle": "DUMMY POSITION",
"positionCode": "S12345",
"status": "Active",
"wls":3,
"revisionDate" : f"2026-01-23",
"description": "",
"department" : 1
},
},
{
"positionTitle": "Junior Data Analyst",
"positionCode": "S39568",
"status": "Active",
"wls":4,
"revisionDate" : f"2026-01-31",
"description": "",
"department" : 1
},
{
"positionTitle": "Student Manager",
"positionCode": "S74933",
"status": "Active",
"wls":5,
"revisionDate" : f"2026-04-01",
"description": "",
"department" : 1
},
{
"positionTitle": "IT Technician",
"positionCode": "S94932",
"status": "Active",
"wls":6,
"revisionDate" : f"2026-05-03",
"description": "",
"department" : 1
},
{
"positionTitle": "Human code generator",
"positionCode": "S22222",
"status": "Active",
"wls":1,
"revisionDate" : f"2026-05-03",
"description": "",
"department" : 1
},
{
"positionTitle": "Senior Software Engineer",
"positionCode": "S00000",
"status": "Active",
"wls":6,
"revisionDate" : f"2026-05-03",
"description": "",
"department" : 1
}

]
PositionHistory.insert_many(positionHistory).on_conflict_replace().execute()
Expand Down