-
Notifications
You must be signed in to change notification settings - Fork 0
Adding an Allocation Review & an Allocation Request Pages #668
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
Open
ArtemKurasov
wants to merge
25
commits into
dep_portal_ad_ManageDepartments
Choose a base branch
from
Artem-alloc-review
base: dep_portal_ad_ManageDepartments
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
51d34b8
Made the Allocation Review page reflect actual requested allocations
ArtemKurasov e19a298
Merge branch 'dep_portal_ad_ManageDepartments' into Artem-alloc-review
ArtemKurasov 09132b1
Updated the layout of the Allocation Review Form + updated the database
ArtemKurasov fc21863
Add popovers for the Allocation Review page
ArtemKurasov 4d1bd2e
Forbade opening the Allocation Review page if the allocation is alrea…
ArtemKurasov f3e0339
Made the Approve button save the Allocation Review form
ArtemKurasov 37e6fbb
THe approvedBy and approvedOn are now saved with the submission of an…
ArtemKurasov aa78f71
Created a new Allocation Request page
ArtemKurasov e4c0d29
Made the Allocation Request form get saved to the database
ArtemKurasov f3833f7
Cleaned up the code
ArtemKurasov 083e556
Merge branch 'dep_portal_ad_ManageDepartments' into Artem-alloc-review
ArtemKurasov 73b3ac4
Reformatted the code for the Allocation Review and Allocation Request…
ArtemKurasov 5585ef0
Updated some of the logic
ArtemKurasov e4c7895
Added tests for the newly created logic functions
ArtemKurasov 582a393
Made the getOrUpdateRequestedAllocation function not depend on the cu…
ArtemKurasov d8a6635
Added a new getCurrentAndNextYear() function + tests for it
ArtemKurasov 731ab49
Updated the demo data and the getCurrentAndNextAY function to use g.c…
ArtemKurasov 5a24ad2
Fixed some backend issues + Allowed inactive departments to submit al…
ArtemKurasov 1fef151
Updated the styles for the Allocation Request and Allocation Review f…
ArtemKurasov dd23662
Allowed labor office students to access the Allocation Review page
ArtemKurasov 3727d18
Allowed labor office students to access the Allocation Request page
ArtemKurasov 0e217b9
Allowed labor office students to access other pages for admins
ArtemKurasov 677adc0
Merge branch 'dep_portal_ad_ManageDepartments' into Artem-alloc-review
ArtemKurasov 3e83e9d
Moved from the generateAdjacentYears() function to getCurrentAndNextAY
ArtemKurasov 14b9365
Reflected on the changes Imran had suggested
ArtemKurasov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from flask import g | ||
| from app.models.term import * | ||
|
|
||
| def getCurrentAndNextAY(): | ||
| """ | ||
| Returns two Term peewee objects: one is the current academic year, | ||
| and the other is the next academic year (note that a new academic year | ||
| begins from the start of July). | ||
| """ | ||
|
|
||
| currentYear = g.currentYear[0] | ||
| nextYear = currentYear + 1 | ||
|
|
||
| currentAYCode = currentYear * 100 | ||
| nextAYCode = nextYear * 100 | ||
|
|
||
| currentAY, _ = Term.get_or_create( | ||
| termCode=currentAYCode, | ||
| defaults={"termName": "AY {}-{}".format(currentYear, currentYear + 1), "isAcademicYear": True} | ||
| ) | ||
|
|
||
| nextAY, _ = Term.get_or_create( | ||
| termCode=nextAYCode, | ||
| defaults={"termName": "AY {}-{}".format(nextYear, nextYear + 1), "isAcademicYear": True} | ||
| ) | ||
|
|
||
| return (currentAY, nextAY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from flask import request, g | ||
| from app.models.allocation import Allocation | ||
| from app.logic.allocationManager import * | ||
| from app.logic.academicYearManager import getCurrentAndNextAY | ||
|
|
||
|
|
||
| def getOrUpdateRequestedAllocation(): | ||
| """ | ||
| Gets or updates the requested allocation (used for the Allocation Request page specificially). | ||
| """ | ||
| currentAY, nextAY = getCurrentAndNextAY() | ||
|
|
||
| requester = request.form.get("submitter", type=int, default=None) # the requesting department | ||
|
|
||
| # the list of the fields updated after submitting the allocation request | ||
| updatedFields = { | ||
| "termCode": nextAY, | ||
| "department": requester, | ||
| "isFinal": False, | ||
| "justification": request.form.get("justification", default=""), | ||
| "primary_10": request.form.get("primary_10", type=int, default=None), | ||
| "primary_12": request.form.get("primary_12", type=int, default=None), | ||
| "primary_15": request.form.get("primary_15", type=int, default=None), | ||
| "primary_20": request.form.get("primary_20", type=int, default=None), | ||
| "secondary_5": request.form.get("secondary_5", type=int, default=None), | ||
| "secondary_10": request.form.get("secondary_10", type=int, default=None), | ||
| "breakHours": request.form.get("breakHours", type=int, default=None) | ||
| } | ||
|
|
||
| # saving the newly approved allocation | ||
| requestedAlloc, wasCreated = Allocation.get_or_create(termCode=nextAY, department=requester, isFinal=False, defaults={**updatedFields}) | ||
|
|
||
| if not wasCreated: # if the allocation has already existed (it is being resubmitted/updated) | ||
| for key, value in updatedFields.items(): | ||
| setattr(requestedAlloc, key, value) # updating all the fields based on updatedFields values | ||
|
|
||
| requestedAlloc.save() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
reroute it to managedepartment instead