-
Notifications
You must be signed in to change notification settings - Fork 0
Create a page for departments to view their allocations #667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: department-portal-base
Are you sure you want to change the base?
Changes from 38 commits
0eb3bb1
5ab2dca
ce23c09
05216d0
c8f12b1
beaba49
e981118
fd7c2c6
ddad2d2
eb4e0af
9eaf061
64f4dc4
c3e9cc1
5350883
f9670d3
23e84d1
54a3f13
cc374dc
827f390
5978774
32f8f6b
5110359
071232b
0760c5d
fa4a35c
5f44de5
764db13
b67164b
cdfbae5
2736b90
22a1856
2005c87
b9f9cc4
96ffe5f
ea29109
73af911
76a167b
f74fb7d
e4b2bc0
8c417f7
6299820
4b2ece2
1e4d1d4
18f1abc
7b0cd5a
8ef2325
a38dc46
9c7b727
47f4f57
26be0a4
b3ec72e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify | ||
| from peewee import JOIN, DoesNotExist, fn | ||
| from functools import reduce | ||
| from datetime import datetime, date | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Total Contracts row should have a tooltip or event like Primary + Secondary total Contract to show that total contracts mean a combination of both as here you have for both primary and secondary table and that can confuse anyone who are not familiar with the term contract as this isn't labor who is using it is all the departments and supervisor who might not be familiar with the term.
|
||
| import operator | ||
|
|
||
| from app.models.department import Department | ||
|
|
@@ -11,6 +12,7 @@ | |
| from app.models.formHistory import FormHistory | ||
| from app.models.term import Term | ||
| from app.models.positionHistory import PositionHistory | ||
| from app.models.allocation import Allocation | ||
|
|
||
| from app.controllers.admin_routes.allPendingForms import checkAdjustment | ||
| from app.controllers.main_routes import main_bp | ||
|
|
@@ -22,6 +24,7 @@ | |
| from app.logic.banner import Banner | ||
| from app.logic.getSupervisors import getSupervisors | ||
| from app.logic.getPositions import getActivePositions | ||
| from app.logic.allocationManager import * | ||
|
fritzj2 marked this conversation as resolved.
Outdated
|
||
|
|
||
|
|
||
| @main_bp.route('/logout', methods=['GET']) | ||
|
|
@@ -82,6 +85,71 @@ def departmentPortal(org=None,account=None): | |
| positions = positionsList, | ||
| posURL = posURL) | ||
|
|
||
| @main_bp.route('/department/<org>/<account>/allocations', methods=['GET']) | ||
| def allocationTable(org=None, account=None): | ||
| currentUser = g.currentUser | ||
| try: | ||
| dept = Department.get(Department.ORG == org, Department.ACCOUNT == account) | ||
| except (NameError, DoesNotExist): | ||
|
fritzj2 marked this conversation as resolved.
|
||
| dept = None | ||
|
|
||
| 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 | ||
|
|
||
|
|
||
| currentDate = date.today() | ||
| if currentDate.month <= 6: | ||
| # If it is the spring semester, then the term code is 1 year behind. e.g. 2025-2026 term code is 202500. Thus the - 100 in the spring term. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be in a logic file and have test, I am not going to require you as this is simple logic but many simple logic. However having different combination of math after currentDate.year means this can be turn into a logic function that determines the termcode and we will see similar termcode logic being use in other branches like allocation request. |
||
| # The (year * 100) turns the year into an AY term code, 2025 -> 202500. The + 12/11 turns it into a fall or spring term. | ||
| springTerm = Term.select().where(Term.termCode == currentDate.year * 100 + 12 - 100).get() | ||
| currentAY = Term.select().where(Term.termCode == currentDate.year * 100 - 100).get() | ||
| fallTerm = Term.select().where(Term.termCode == currentDate.year * 100 + 11 - 100).get() | ||
|
|
||
| else: | ||
| fallTerm = Term.select().where(Term.termCode == currentDate.year * 100 + 11).get() | ||
| currentAY = Term.select().where(Term.termCode == currentDate.year * 100).get() | ||
| springTerm = Term.select().where(Term.termCode == currentDate.year * 100 + 12).get() | ||
|
|
||
| allocationDict = getTotalAllocations(currentAY, dept) | ||
|
fritzj2 marked this conversation as resolved.
Outdated
|
||
| fallContracts = getContractedAllocations(fallTerm, dept) | ||
| springContracts = getContractedAllocations(springTerm, dept) | ||
|
|
||
| breakContracts = { | ||
| "total": 0, | ||
| "thanksgiving":getBreakContracts(currentAY.termCode + 1, dept), | ||
| "winter": getBreakContracts(currentAY.termCode + 2, dept), | ||
| "spring": getBreakContracts(currentAY.termCode + 3, dept), | ||
| "fall":getBreakContracts(currentAY.termCode + 4, dept), | ||
| "summer": getBreakContracts(currentAY.termCode + 13, dept) | ||
| } | ||
| breakContracts["total"] = sum(breakContracts.values()) | ||
| return render_template('main/allocationTable.html', | ||
| department = dept, | ||
| currentAY = currentAY, | ||
| allocations = allocationDict, | ||
| fallContracts = fallContracts, | ||
| springContracts = springContracts, | ||
| breakContracts = breakContracts) | ||
|
|
||
|
|
||
| @main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST']) | ||
| def addUserToDept(): | ||
|
fritzj2 marked this conversation as resolved.
Outdated
|
||
| userDeptData = request.form | ||
| supervisorDeptRecord = SupervisorDepartment.get_or_none(supervisor = userDeptData['supervisorID'], department = userDeptData['departmentID']) | ||
| try: | ||
| if supervisorDeptRecord: | ||
| return "False" | ||
|
|
||
| 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('/supervisorPortal/download', methods=['POST']) | ||
| def downloadSupervisorPortalResults(): | ||
| ''' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| .grid-container { | ||
| display: grid; | ||
| grid-template-columns: 1fr 1fr; | ||
| } | ||
| .btn-success{ | ||
| align-self: center; | ||
| justify-self: end; | ||
| } | ||
| .card-header { | ||
| background-color: #efebeb; | ||
| margin-bottom: 7px; | ||
| height: 6rem; | ||
| } | ||
| .mb-0, .collapsed { | ||
| outline-color: none; | ||
| color: black; | ||
| font-size: 18px; | ||
| font-weight: 525; | ||
| } | ||
| .collapse{ | ||
| padding-left: 5% ; | ||
| padding-right: 5%; | ||
| } | ||
| .accordion{ | ||
| padding-left: 5%; | ||
| padding-right: 5%; | ||
| } | ||
| .table-striped { | ||
| table-layout:fixed; | ||
| width:100%; | ||
| } | ||
| .table-striped tbody tr:nth-of-type(odd) { | ||
| background-color: #f2f2f2; | ||
| } | ||
| .btn-info{ | ||
| justify-self:flex-end; | ||
| align-self: center; | ||
| margin-left: 4px | ||
| } | ||
| .accordion-arrow { | ||
| display: inline-block; | ||
| transition: transform 0.2s ease-in-out; | ||
| } | ||
| .btn.collapsed .accordion-arrow { | ||
| transform: rotate(-90deg); | ||
| } | ||
| .btn:not(.collapsed) .accordion-arrow { | ||
| transform: rotate(0deg); | ||
| } | ||
| .button-container { | ||
| display:flex; | ||
| justify-content:end; | ||
| } | ||
| .btn-block{ | ||
| align-items: center; | ||
| align-self: center; | ||
| text-align: center; | ||
| justify-content: center; | ||
| height: 100% | ||
| } | ||
| .termDisplay{ | ||
| margin-right:auto; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| $(document).ready( function(){ | ||
| function initTable(selector) { | ||
| return $(selector).DataTable({ | ||
| pageLength: 25, | ||
| info: false, | ||
| lengthChange: false, | ||
| searching: false, | ||
| paging: false, | ||
| order: [] | ||
| }); | ||
| } | ||
|
|
||
| const fallTermPrimaries = initTable('#fallTermPrimaries'); | ||
| const fallTermSecondaries = initTable('#fallTermSecondaries'); | ||
| const springTermPrimaries = initTable('#springTermPrimaries'); | ||
| const springTermSecondaries = initTable('#springTermSecondaries'); | ||
| const breakTable = initTable('#breakTable'); | ||
| }); |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.