Skip to content

Create a page for departments to view their allocations - #667

Merged
MImran2002 merged 62 commits into
department-portal-basefrom
allocation_table
Aug 25, 2026
Merged

Create a page for departments to view their allocations#667
MImran2002 merged 62 commits into
department-portal-basefrom
allocation_table

Conversation

@fritzj2

@fritzj2 fritzj2 commented Aug 5, 2026

Copy link
Copy Markdown

Issue Description

Fixes issue #607

  • Create a page for departments to view their current allocations. This should include both contracts and given allocations for the current term
image

Additions

  • allocationTable html, css, and js, all handle the UI.
  • allocationTable.js is needed because there are 6 Bootstrap DataTables on the page.
  • getTerms.py has been added to handle getting the current term
  • test_getTerms.py to test the logic behind getTerms.py

Changes

  • main_routes.py includes a section that navigates to the page
  • The allocationManager.py file includes 1 new function, getContractedAllocations(). This function gathers the number of hours for the break terms.
  • Lots of new objects in demo_data.py, which include more LSFs, formHistory, students, and terms.

Rationale

  • This logic depends on having access to a term that aligns with the current year. main_routes.py contains a function that retrieves the current date and uses its year-end to determine the current term.

    • This term check flips on July 1st, as it is the day when the terms change for the labor office.
    • This check exists to get around there being no sense of a currentTerm in the system
  • The page will not physically load if there is no term for the current year.

  • The page also fails to load if there is no Allocation object for the current term.

  • Retrieving formHistory objects has a lot of nuance to it.

  • Contracts have many different ways that they can be written for only one term, including:

    • Changing term to Fall 2026 / Spring 2026
    • Changing the start / end date to the end of a semester
    • The kind of position (Primary vs Secondary)
    • The type of position (Weekly Hours vs Contract Hours)
  • The Reasoning behind the complex query is that there are many different ways in which a Labor Status form differentiates term contracts, yearly contracts, and break contracts.

  • The Supervisors can pick whichever way they choose to build the Labor Status Form, and the function needs to be prepared to deal with all of the cases present.

  • Breaks are hard to justify their place in the table. As nice as they are, it is hard to see the information that someone may want at a given time

  • The current implementation has all of the break allocations for a selected term. The problem is the summer term.

  • Summer term starts after fall term.

    • The problem is that after July 1st, the next year's summer information will be displayed.
    • This is helpful as most of the longer summer term positions are finalized
      • As for the contracts that start after July 1st (think RAs who start ~August 1st), they can't be viewed since the term has rolled over.
  • As for the getTerms.py, this does not grab break terms.

    • The reason that break terms are not included in this is that there are simply too many and too few use cases for them.
    • It is already hard to justify adding the spring and fall terms into the query; however, adding 5 more terms to it seems unnecessary in many cases and thus have been omitted.

Testing

  • Reset the database to test data (or the allocation grab function breaks the page)
  • Navigate into the allocations page (home page -> Department Portal -> Computer Science -> Allocation Card -> View Allocations)
    • Other departments require an allocation model to be added for the page to load.
      • INSERT INTO allocation (id, department_id, isFinal, termCode_id, justification, primary_10, primary_12, primary_15, primary_20, secondary_5, secondary_10, breakHours) VALUES (222, 2, 1, 202600, "ETAD allocation", 1,1,1,1,1,1,111); will give you an allocation for the ETAD department, which will load the page afterward.
  • View the tables nested in the accordions, ensure that it is pulling formHistory and allocations
  • Ensure that users not part of a specified department cannot access another department's page.
    • The quickest way to test this is by changing users in secret_config.yaml
  • Mess with the data, ensure that the page loads with no contracts.
  • Check what happens with bad LSFs added to the data, such as with dates, terms, jobTypes, and contractHours.
  • Check the test suite and ensure all tests are passing
  • Check that the test_allocationManager.py test is passing, most importantly.

@fritzj2
fritzj2 marked this pull request as ready for review August 6, 2026 19:32
Comment thread app/controllers/main_routes/main_routes.py
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a tool-tip to each category of the Total contracts which reads "Total Contracts shows the count for both Primaries and Secondaries for the term".
It may also be worthwhile to consider removing the Total Contracts from the secondaries table to avoid the redundancy.

Comment thread app/controllers/main_routes/main_routes.py

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made getTerm.py to handle the logic behind this; it does more than just get the current term. Tossing in an academic year gives the user the AY, fall, and spring terms for that Academic year. If the Academic year is not provided, it gets the current term.

@MImran2002

Copy link
Copy Markdown
Contributor

Aside from the requested these are the scenarios I have checked and what i can say is it works, different term forms don't affect the current ay term display. when a lsf is submitted the display shows corrected and when i modify the form into different hours the display shows correctly too.

@MImran2002
MImran2002 merged commit f0ab813 into department-portal-base Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants