-
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 all 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
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 |
|---|---|---|
|
|
@@ -37,13 +37,36 @@ def getTotalAllocations(termCode: int, dept: int): | |
| "totalAllocations": (allocationObject["primary_10"] + allocationObject["primary_12"] + allocationObject["primary_15"] + allocationObject["primary_20"] + allocationObject["secondary_5"] + allocationObject["secondary_10"] )} | ||
| return allocationDict | ||
|
|
||
| def countContracts(jobType: str, weeklyContractHours: int, termCode: int, dept: int): | ||
| def countContracts(jobType: str, weeklyContractHours: int, termCode: int, dept: int, AYtermCode: int = None): | ||
| ''' | ||
| This function counts the number of positions of a given type in a given department. | ||
| For example, countContracts('secondary', 5, 202511, 1) returns the number of secondary | ||
| 5-hour positions in the CS department for the 2025 Fall term. | ||
| ''' | ||
| academicYearCode = int(str(termCode)[:4] + "00") | ||
|
|
||
| # This sets the date condition to determine whether the form is within the boundaries of the term | ||
| # Fall only contracts end before spring, spring contracts start after fall. | ||
| fallMonths = ["07","08","09","10","11","12"] | ||
|
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 we clean up this date filtering? This currently compares extracted month values to string values like
Author
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. As interesting a concept as it sounds, the impact on code performance here is almost negligible. In the end, the check for the year-long positions checks the end-of-year dates anyway. e.g. (lsf.startDate >= AY.startDate) & lsf.startDate <= AY.endDate).
The end code requires many comparisons, which makes the already hard-to-read code even harder to read and debug, for very little benefit. |
||
| springMonths = ["01","02","03","04","05","06"] | ||
| if str(termCode).endswith("11"): | ||
| dateCondition = ( | ||
| (LaborStatusForm.endDate.month.in_(fallMonths)) | | ||
| (LaborStatusForm.startDate.month.in_(fallMonths) & # Reused check for year-long positions | ||
| LaborStatusForm.endDate.month.in_(springMonths)) | ||
| ) | ||
| elif str(termCode).endswith("12"): | ||
| dateCondition = ( | ||
| (LaborStatusForm.startDate.month.in_(springMonths)) | | ||
| (LaborStatusForm.startDate.month.in_(fallMonths) & | ||
| LaborStatusForm.endDate.month.in_(springMonths)) | ||
| ) | ||
| else: | ||
| dateCondition = ( | ||
| (LaborStatusForm.startDate.month.in_(fallMonths) & | ||
| LaborStatusForm.endDate.month.in_(springMonths)) | ||
| ) | ||
|
|
||
| lsfCountPositions = FormHistory.select( | ||
| ).join(LaborStatusForm | ||
| ).join(Department | ||
|
|
@@ -54,6 +77,7 @@ def countContracts(jobType: str, weeklyContractHours: int, termCode: int, dept: | |
| LaborStatusForm.jobType == jobType, # 'primary' or 'secondary' | ||
| LaborStatusForm.weeklyHours == weeklyContractHours, # 5, 10, 12, 15, or 20 | ||
| Department.departmentID == dept, | ||
| dateCondition, | ||
| ).count() | ||
| return lsfCountPositions | ||
|
|
||
|
|
@@ -105,4 +129,18 @@ def getContractedAllocations(termCode: int, dept: int): | |
| usedPositions["used_primaries"] = sum(list(usedPositions.values())[:4]) | ||
| usedPositions["used_secondaries"] = sum(list(usedPositions.values())[4:6]) | ||
| usedPositions["used_total"] = sum(list(usedPositions.values())[:6]) | ||
| return usedPositions | ||
| return usedPositions | ||
|
|
||
| def getBreakContracts(termCode, dept): | ||
| break_allocation = FormHistory.select(fn.SUM(LaborStatusForm.contractHours) | ||
| ).join(LaborStatusForm | ||
| ).where( | ||
| FormHistory.historyType == "Labor Status Form", | ||
| FormHistory.status.in_(["Approved", "Pending", "Pre-Student Approval"]), | ||
| LaborStatusForm.termCode == termCode, | ||
| LaborStatusForm.department == dept, | ||
| LaborStatusForm.contractHours.is_null(False)).scalar() | ||
| if break_allocation != None: | ||
| return break_allocation | ||
| else: | ||
| return 0 | ||
| 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'); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.