diff --git a/app/controllers/admin_routes/manage_departments.py b/app/controllers/admin_routes/manage_departments.py index 6b16877c..2cccbcad 100644 --- a/app/controllers/admin_routes/manage_departments.py +++ b/app/controllers/admin_routes/manage_departments.py @@ -1,4 +1,5 @@ from app.controllers.admin_routes import * +from app.models import term from app.models.user import * from app.models.supervisorDepartment import SupervisorDepartment from app.login_manager import require_login @@ -9,11 +10,14 @@ from app.models.term import * from flask_bootstrap import bootstrap_find_resource from app.models.department import * +from app.models.allocation import * +from app.models.laborStatusForm import * #Do we need to import all? from flask import request, redirect from flask import jsonify from playhouse.shortcuts import model_to_dict from app.logic.tracy import Tracy + @admin.route('/admin/manageDepartments', methods=['GET']) # @login_required def manage_departments(): @@ -31,20 +35,48 @@ def manage_departments(): elif currentUser.supervisor: return render_template('errors/403.html'), 403 + #FIXME: hardcoded term year for the testing purposes + currentTerm = 202500 + + print("Current term: ", currentTerm) + - activeDepartments = Department.select().where(Department.isActive == True) + # activeDepartments = Department.select().where(Department.isActive == True) + # allAllocations = Allocation.select().where(Allocation.termCode == currentTerm) inactiveDepartments = Department.select().where(Department.isActive == False) + + academicYear = ( + Term.get(Term.termCode == currentTerm).termName +) + academicYear = Term.get(Term.termCode == currentTerm).termName + + activeDepartments = ( + Department + .select(Department, Allocation) + .join(Allocation) + .where( + Department.isActive == True, + Allocation.termCode == currentTerm + ) + + +) + allSupervisors= Supervisor.select().order_by(Supervisor.LAST_NAME) return render_template( 'admin/manageDepartments.html', title = ("Manage Departments"), activeDepartments = activeDepartments, inactiveDepartments = inactiveDepartments, - allSupervisors = allSupervisors + allSupervisors = allSupervisors, + currentTerm = currentTerm, + academicYear = academicYear ) except Exception as e: print("Error Loading all Departments", e) return render_template('errors/500.html'), 500 + + @admin.route("/admin/manageDepartments/", methods=['GET']) def getSupervisorsInDepartment(departmentID): currentUser = require_login() diff --git a/app/controllers/main_routes/departmentPortal.py b/app/controllers/main_routes/departmentPortal.py new file mode 100644 index 00000000..35175770 --- /dev/null +++ b/app/controllers/main_routes/departmentPortal.py @@ -0,0 +1 @@ +from flask import render_template diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index b3af06c9..0a2f21e4 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -1,5 +1,5 @@ from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify -from peewee import JOIN +from peewee import JOIN, DoesNotExist from functools import reduce import operator from app.models.department import Department @@ -47,6 +47,26 @@ def supervisorPortal(): currentUser = currentUser ) +@main_bp.route('/department', methods=['GET']) +@main_bp.route('/department/', methods=['GET']) +@main_bp.route('/department//', methods=['GET']) +def departmentPortal(org=None,account=None): + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except (NameError, DoesNotExist): + dept = None + + + + if g.currentUser.isLaborAdmin: + departments = list(Department.select().order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) + else: + departments = list(getDepartmentsForSupervisor(g.currentUser).order_by(Department.isActive.desc(), Department.DEPT_NAME.asc())) + + return render_template('main/departmentPortal.html', + departments = departments, + department = dept) + @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): userDeptData = request.form @@ -113,4 +133,4 @@ def submitToBanner(formHistoryId): if save_form_status: return "Form successfully submitted to Banner.", 200 else: - return "Submitting to Banner failed.", 500 \ No newline at end of file + return "Submitting to Banner failed.", 500 diff --git a/app/models/allocation.py b/app/models/allocation.py new file mode 100644 index 00000000..75f9c828 --- /dev/null +++ b/app/models/allocation.py @@ -0,0 +1,19 @@ +from app.models import * +from app.models.department import Department +from app.models.supervisor import Supervisor +from app.models.term import Term + +class Allocation(baseModel): + termCode = ForeignKeyField(Term) + department = ForeignKeyField(Department) + isApproved = BooleanField(default=False) + approvedOn = DateField(null =True) + approvedBy = ForeignKeyField(Supervisor, null =True) + justification = TextField() + primary_10 = IntegerField() + primary_12 = IntegerField() + primary_15 = IntegerField() + primary_20 = IntegerField() + secondary_5 = IntegerField() + secondary_10 = IntegerField() + breakHours = IntegerField() diff --git a/app/models/positionHistory.py b/app/models/positionHistory.py new file mode 100644 index 00000000..f255dfbc --- /dev/null +++ b/app/models/positionHistory.py @@ -0,0 +1,10 @@ +from app.models import * +from app.models.department import Department + +class PositionHistory(baseModel): + positioncode = PrimaryKeyField() + status = CharField() + WLS = IntegerField() + revisiondate = DateField() + Description = TextField() + Department = ForeignKeyField(Department) diff --git a/app/models/supervisorDepartment.py b/app/models/supervisorDepartment.py index 3585e1eb..72a80ea6 100644 --- a/app/models/supervisorDepartment.py +++ b/app/models/supervisorDepartment.py @@ -5,3 +5,12 @@ class SupervisorDepartment(baseModel): supervisor = ForeignKeyField(Supervisor, null=True) department = ForeignKeyField(Department) + banStatus = BooleanField(default=False) + isActive = BooleanField(default=False) + isCoordinator = BooleanField(default=False) + + @property + def isBanned(self): + return self.banStatus + + diff --git a/app/static/css/base.css b/app/static/css/base.css index 916fb4db..940f8d6e 100755 --- a/app/static/css/base.css +++ b/app/static/css/base.css @@ -191,3 +191,76 @@ a { font-size:1.2em; z-index:999; } + +.card { + position: relative; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + min-width: 0; + word-wrap: break-word; + background-color: #fff; + background-clip: border-box; + border: 1px solid rgba(0, 0, 0, 0.125); + border-radius: 0.25rem; +} + +.card-body { + -webkit-box-flex: 1; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + padding: 1rem 1rem; +} + +.card-title { + margin-bottom: 0.5rem; + font-size: 1.25rem; + font-weight: 500; +} + +.card-subtitle { + margin-top: -0.25rem; + margin-bottom: 0; +} + +.card-text:last-child { + margin-bottom: 0; +} + +.card-link + .card-link { + margin-left: 1rem; +} + +.card-header { + padding: 0.5rem 1rem; + margin-bottom: 0; + background-color: rgba(0, 0, 0, 0.03); + border-bottom: 1px solid rgba(0, 0, 0, 0.125); +} + +.card-header:first-child { + border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0; +} + +.card-footer { + padding: 0.5rem 1rem; + background-color: rgba(0, 0, 0, 0.03); + border-top: 1px solid rgba(0, 0, 0, 0.125); +} + +.card-footer:last-child { + border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px); +} + +.card-img, .card-img-top { + width: 100%; +} + +.card-img-top { + border-top-left-radius: calc(0.25rem - 1px); + border-top-right-radius: calc(0.25rem - 1px); +} diff --git a/app/static/css/manageDepartments.css b/app/static/css/manageDepartments.css index 81fcfb05..df77648f 100755 --- a/app/static/css/manageDepartments.css +++ b/app/static/css/manageDepartments.css @@ -34,4 +34,10 @@ h1 { #flasher{ z-index: 999999; +} + +#activeDepartmentsTable th, +#activeDepartmentsTable td { + vertical-align: middle; + text-align: center; } \ No newline at end of file diff --git a/app/static/js/departmentPortal.js b/app/static/js/departmentPortal.js new file mode 100644 index 00000000..cb2023a3 --- /dev/null +++ b/app/static/js/departmentPortal.js @@ -0,0 +1,6 @@ +$(document).ready(function() { + $("#selectedDepartment").on("change",function() { + deptData = $(this).find('option:selected').data(); + window.location = `/department/${deptData.org}/${deptData.account}`; + }); +}); diff --git a/app/templates/admin/manageDepartments.html b/app/templates/admin/manageDepartments.html index ddb1b043..54dbddc3 100755 --- a/app/templates/admin/manageDepartments.html +++ b/app/templates/admin/manageDepartments.html @@ -1,134 +1,271 @@ -{% extends "base.html" %} - -{% block styles %} -{{super()}} - - -{% endblock %} - -{% block scripts %} -{{super()}} - - - -{% endblock %} - -{% block app_content %} +{% extends "base.html" %} {% block styles %} {{super()}} + + +{% endblock %} {% block scripts %} {{super()}} + + + +{% endblock %} {% block app_content %}
Click to Skip
-
- Click to Skip -
-
-

Manage Departments

+
+ Click to Skip +
+
+

Manage Departments

-

Position descriptions are up to date.

-

Position descriptions are not up to date

+

+ Monitor allocation usage, compliance, and department position needs + across campus. +

-
-
-
+

+ + Position descriptions are up to date. +

+

+ + Position descriptions are not up to date +

+ +
-
- -
-
- +
-
-
- - - - - - - - - {% for department in activeDepartments %} - - - - - {% endfor %} - -
DepartmentStatus
{{department.DEPT_NAME}}({{department.ORG}}, {{department.ACCOUNT}}) - -
-
+
+
+ + +
+
+ + +
+
-
- - - - - - - - {% for department in inactiveDepartments %} - - - - {% endfor %} - -
Department
{{department.DEPT_NAME}}({{department.ORG}}, {{department.ACCOUNT}})
-
+
+
+
+ -
+
+ +
+ + + + + + + + + + + + + {% for department in activeDepartments %} + + + + + + + + + + + + + + {% endfor %} + + +
DepartmentStatusPositionsAllocation Approval Status {{ academicYear }}Break Hours Used/GivenActions
+ {{department.DEPT_NAME}}({{department.ORG}}, {{department.ACCOUNT}}) + + + +

Prim: 6 of 16

+

Sec: 12 of 16

+
+ + + {{ department.allocation.breakHours }} + + + +
+
+ +
+ + + + + + + + {% for department in inactiveDepartments %} + + + + {% endfor %} + +
Department
+ {{department.DEPT_NAME}}({{department.ORG}}, {{department.ACCOUNT}}) +
+
+
+
-