diff --git a/app/controllers/main_routes/main_routes.py b/app/controllers/main_routes/main_routes.py index 0a2f21e4..55c0b759 100755 --- a/app/controllers/main_routes/main_routes.py +++ b/app/controllers/main_routes/main_routes.py @@ -16,6 +16,8 @@ from app.login_manager import require_login, logout from app.logic.getTableData import getDatatableData from app.logic.banner import Banner +from app.logic.tracy import Tracy +from app.models.activeposition import Activeposition @main_bp.route('/logout', methods=['GET']) def triggerLogout(): @@ -51,21 +53,55 @@ def supervisorPortal(): @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): + if org and account: + try: + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except (NameError, DoesNotExist): + dept = None + else: 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())) + + pos = Tracy().getPositionsFromDepartment(org, account) + positions = [] + for i in pos: + positions.append(i.POSN_TITLE + "" + "(" + i.WLS + ")") + + staff = Tracy().getSupervisors() + supervisors = [] + + for i in staff: + if i.ORG == org: + supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")") return render_template('main/departmentPortal.html', departments = departments, - department = dept) + department = dept, + positions = positions, + supervisors = supervisors + ) + +@main_bp.route('/department///positions', methods=['GET']) +def managePositions(org, account): + try: + currentUser = require_login() + if not currentUser or not currentUser.supervisor: + return render_template('errors/403.html'), 403 + dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) + except DoesNotExist: + return render_template('errors/404.html'), 404 + print("THIS IS Dept:", dept) + positions = list(Activeposition.select().where(Activeposition.Department == dept)) + print(f"Positions for department {dept.DEPT_NAME}, ID {dept.id}: {[p.title for p in positions]}") + return render_template('main/managepositions.html', + department = dept, + department_name = dept.DEPT_NAME, + positions = positions + ) @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) def addUserToDept(): diff --git a/app/models/activeposition.py b/app/models/activeposition.py new file mode 100644 index 00000000..99832f0f --- /dev/null +++ b/app/models/activeposition.py @@ -0,0 +1,12 @@ +from app.models import * +from app.models.department import Department + +class Activeposition(baseModel): + title = CharField() + positioncode = CharField() + status = CharField(default="Approved") + WLS = IntegerField() + revisiondate = DateField() + Description = TextField(default=None) + Department = ForeignKeyField(Department) + diff --git a/app/models/allocation.py b/app/models/allocation.py new file mode 100644 index 00000000..86e905c0 --- /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() + 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..95fb3d28 --- /dev/null +++ b/app/models/positionHistory.py @@ -0,0 +1,13 @@ +from app.models import * +from app.models.department import Department + +class PositionHistory(baseModel): + positioncode = CharField() + status = CharField() + WLS = IntegerField() + revisiondate = DateField() + Description = TextField(default=None) + Department = ForeignKeyField(Department) + + class Meta: + primary_key = CompositeKey('positioncode', 'revisiondate', 'status') \ No newline at end of file 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/managepositions.css b/app/static/css/managepositions.css new file mode 100644 index 00000000..af9151ea --- /dev/null +++ b/app/static/css/managepositions.css @@ -0,0 +1,17 @@ +.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; +} \ No newline at end of file diff --git a/app/static/js/managePositions.js b/app/static/js/managePositions.js new file mode 100644 index 00000000..ab7e29dc --- /dev/null +++ b/app/static/js/managePositions.js @@ -0,0 +1,9 @@ +$(document).ready(function () { + $('#positionTable').DataTable({ + pageLength: 25, + columnDefs: [ + { className: 'dt-head-center', targets: '_all' }, + { orderable: false, targets: [4, 5] } + ] + }); +}); diff --git a/app/templates/main/departmentPortal.html b/app/templates/main/departmentPortal.html index 8ee01838..0e4b528d 100644 --- a/app/templates/main/departmentPortal.html +++ b/app/templates/main/departmentPortal.html @@ -3,11 +3,13 @@ {% block scripts %} {{super()}} + {% endblock %} - {% block app_content %}

{% if department %} {{department.DEPT_NAME}} Portal {% else %} Choose a Department: {% endif %}

+
-{% endblock %} + +{% if department %} +
+ +
+
+
+ + + + + Current Allocation +
+


AY 26/27 15/20 POSITIONS

Break Hours 0 of 200 hrs

+ Go somewhere +
+
+ +
+
+
+
+ +
+
+

+ Members +

+
+
+

Labor Coordinator(s)

+

Dr. Jones

+ +

Supervisors

+ {% for s in supervisors %} + {% if 3 > loop.index0 %} +

{{ s }}

+ {% elif 4 > loop.index0 %} +

and {{ supervisors | length}} more...

+ {% endif %} + {% endfor %} +
+ + +
+ +
+
+
+
+

Positions

+
+
+ +
+ +
+
    + {% for p in positions %} + {% if 7 > loop.index0 %} +
  • {{ p }}
  • + {% elif 8 == loop.index0 %} +

and {{ positions | length}} more...

+ {% endif %} + {% endfor %} + + +
+ +
+
+ +{% endif %} + + + + +{% endblock %}\ + + + + diff --git a/app/templates/main/managepositions.html b/app/templates/main/managepositions.html new file mode 100644 index 00000000..740df36a --- /dev/null +++ b/app/templates/main/managepositions.html @@ -0,0 +1,72 @@ +{% extends "base.html" %} + +{% block styles %} +{{super()}} + + +{% endblock %} + +{% block scripts %} +{{super()}} + + +{% endblock %} + +{% block app_content %} + +
+ +

{{ department_name }} Positions

+
+ +
+
+ +
+ + + + + + + + + + + + + + + + {% for position in positions %} + + + + + + + + + {% endfor %} + +
PositionWLSStatusLast Revision DateView Position DescriptionEdit Position Description
{{position.title}} {{position.positioncode}} {{position.WLS}} +

+ {{position.status}} +

+
{{position.revisiondate}} + + + +
+
+

+ Total Positions: + {{ positions|length }} +

+ + +{% endblock %} diff --git a/app/templates/main/supervisorPortal.html b/app/templates/main/supervisorPortal.html index 78383566..3ab521a5 100644 --- a/app/templates/main/supervisorPortal.html +++ b/app/templates/main/supervisorPortal.html @@ -227,7 +227,7 @@

Form Search


-
+