Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/models/allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
class Allocation(baseModel):
termCode = ForeignKeyField(Term)
department = ForeignKeyField(Department)
isApproved = BooleanField(default=False)
approvedOn = DateField(null =True)
approvedBy = ForeignKeyField(Supervisor, null =True)
isFinal = BooleanField(default=False)
approvedOn = DateField(null=True)
approvedBy = ForeignKeyField(Supervisor, null=True)
justification = TextField()
primary_10 = IntegerField()
primary_12 = IntegerField()
Expand All @@ -17,3 +17,6 @@ class Allocation(baseModel):
secondary_5 = IntegerField()
secondary_10 = IntegerField()
breakHours = IntegerField()

class Meta:
indexes = ( (('termCode', 'department', 'isFinal'), True), )
13 changes: 8 additions & 5 deletions app/models/positionHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
from app.models.department import Department

class PositionHistory(baseModel):
positioncode = PrimaryKeyField()
positionCode = CharField()
department = ForeignKeyField(Department)
status = CharField()
WLS = IntegerField()
revisiondate = DateField()
Description = TextField()
Department = ForeignKeyField(Department)
wls = IntegerField()
revisionDate = DateField()
description = TextField(default=None)

class Meta:
indexes = ( (('positionCode', 'revisionDate', 'status'), True), )
1 change: 1 addition & 0 deletions app/models/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Supervisor(baseModel):
legal_name = CharField(null=True)
preferred_name = CharField(null=True)
isActive = BooleanField(default=False)
isBanned = BooleanField(default=False)


@property
Expand Down
4 changes: 1 addition & 3 deletions app/models/supervisorDepartment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from app.models.department import Department

class SupervisorDepartment(baseModel):
supervisor = ForeignKeyField(Supervisor, null=True)
supervisor = ForeignKeyField(Supervisor)
department = ForeignKeyField(Department)
banStatus = BooleanField(default=False)
isActive = BooleanField(default=False)
Expand All @@ -12,5 +12,3 @@ class SupervisorDepartment(baseModel):
@property
def isBanned(self):
return self.banStatus


29 changes: 17 additions & 12 deletions app/templates/admin/manageDepartments.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,23 @@ <h1>Manage Departments</h1>


<td style="white-space: nowrap">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Action
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="#">Allocation History</a></li>
<li><a href="#">Position Review</a></li>
<li><a href="#">Edit Dept Member</a></li>
<li><a href="#">Allocation Review</a></li>
</ul>
</div>
<div class="btn-group" style="display: inline-flex">
<button type="button" class="btn btn-default">Action</button>
<button
type="button"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="{{ url_for('main.departmentPortal', org=department.ORG, account=department.ACCOUNT) }}">Allocation History</a></li>
<li role="separator" class="divider"></li>
<li><a href="{{ url_for('main.departmentPortal', org=department.ORG, account=department.ACCOUNT) }}">Department Personnel</a></li>
</ul>
</div>
</td>
</tr>
Expand Down
33 changes: 20 additions & 13 deletions database/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
from app.models.laborStatusForm import LaborStatusForm
from app.models.formHistory import FormHistory
from app.models.notes import Notes
from app.models.supervisorDepartment import SupervisorDepartment
from app.models.allocation import Allocation
from app.models.positionHistory import PositionHistory
from app.models.supervisorDepartment import SupervisorDepartment
from app.models.allocation import Allocation
from app.models.positionHistory import PositionHistory


print("Inserting data for demo and testing purposes")
Expand Down Expand Up @@ -516,6 +514,15 @@
current_year = today.year - (today.month < 8)

terms = [
{
"termCode": f"202000",
"termName": f"AY 2020-2021",
"termStart": f"2020-08-01",
"termEnd": f"2021-05-01",
"termState": 0,
"primaryCutOff": f"2020-09-01",
"adjustmentCutOff": f"2020-10-01",
},
{
"termCode": f"{current_year}00",
"termName": f"AY {current_year}-{current_year+1}",
Expand Down Expand Up @@ -583,7 +590,7 @@
current_year = today.year - (today.month < 8)
LaborStatusForm.insert([{
"laborStatusFormID": 2,
"termCode_id": f"{current_year}00",
"termCode_id": f"202000",
"studentName": "Alex Bryant",
"studentSupervisee_id": "B00841417",
"supervisor_id": "B12361006",
Expand All @@ -593,8 +600,8 @@
"POSN_TITLE": "Student Programmer",
"POSN_CODE": "S61407",
"weeklyHours": 10,
"startDate": f"{current_year}-04-01",
"endDate": f"{current_year}-09-01"
"startDate": f"2020-04-01",
"endDate": f"2020-09-01"
}]).on_conflict_replace().execute()
FormHistory.insert([{
"formHistoryID": 2,
Expand Down Expand Up @@ -713,7 +720,7 @@
{
"termCode": 202200,
"department": 3,
"isApproved": False,
"isFinal": False,
"approvedOn": None,
"approvedBy": None,
"justification": "Downscaling due to decrease in student enrollment caused by current economic conditions",
Expand All @@ -728,7 +735,7 @@
{
"termCode": 202300,
"department": 2,
"isApproved": False,
"isFinal": False,
"approvedOn": None,
"approvedBy": None,
"justification": "Increase in student enrollment due to exodous from CS department",
Expand All @@ -743,7 +750,7 @@
{
"termCode": 202400,
"department": 1,
"isApproved": False,
"isFinal": False,
"approvedOn": None,
"approvedBy": None,
"justification": "We are hiring more students to help with the increased workload in the department",
Expand All @@ -758,7 +765,7 @@
{
"termCode": 202500,
"department": 4,
"isApproved": False,
"isFinal": False,
"approvedOn": None,
"approvedBy": None,
"justification": "Downscaling the number of students in the department due to budget cuts",
Expand All @@ -773,7 +780,7 @@
{
"termCode": 202500,
"department": 5,
"isApproved": False,
"isFinal": False,
"approvedOn": None,
"approvedBy": None,
"justification": "Due to rapid department growth, we need to hire more students to help with the increased workload",
Expand All @@ -794,7 +801,7 @@
{
"termCode":f"{current_year}00",
"department": 3,
"isApproved": True,
"isFinal": True,
"approvedOn": f"{current_year}-06-30",
"approvedBy": "B12365892",
"justification": "We just want it for fun",
Expand All @@ -809,7 +816,7 @@
{
"termCode":f"{current_year}00",
"department": 2,
"isApproved": False,
"isFinal": False,
"approvedOn": f"{current_year}-06-20",
"approvedBy": "B00763721",
"justification": "We need it to lower the amount of allocations we have",
Expand Down
1 change: 1 addition & 0 deletions database/migrate_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pem add app.models.supervisor.Supervisor
pem add app.models.supervisorDepartment.SupervisorDepartment
pem add app.models.studentLaborEvaluation.StudentLaborEvaluation
pem add app.models.formSearchResult.FormSearchResult
pem add app.models.positionHistory.PositionHistory
pem add app.models.allocation.Allocation

pem watch
Expand Down
14 changes: 14 additions & 0 deletions database/prod-backup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1208,3 +1208,17 @@ ALTER TABLE `laborreleaseform`


alter table student add isActive boolean;
alter table supervisor add isBanned boolean;
alter table supervisordepartment add `isCoordinator` BOOL NOT NULL default false;

CREATE TABLE `positionhistory` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `positionCode` VARCHAR(255) NOT NULL, `department_id` INTEGER NOT NULL, `status` VARCHAR(255) NOT NULL, `wls` INTEGER NOT NULL, `revisionDate` DATE NOT NULL, `description` TEXT NOT NULL, FOREIGN KEY (`department_id`) REFERENCES `department` (`departmentID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE INDEX `positionhistory_department_id` ON `positionhistory` (`department_id`);
CREATE UNIQUE INDEX `positionhistory_positionCode_revisionDate_status` ON `positionhistory` (`positionCode`, `revisionDate`, `status`);

CREATE TABLE `allocation` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `termCode_id` INTEGER NOT NULL, `department_id` INTEGER NOT NULL, `isFinal` BOOL NOT NULL, `approvedOn` DATE, `approvedBy_id` VARCHAR(255), `justification` TEXT NOT NULL, `primary_10` INTEGER NOT NULL, `primary_12` INTEGER NOT NULL, `primary_15` INTEGER NOT NULL, `primary_20` INTEGER NOT NULL, `secondary_5` INTEGER NOT NULL, `secondary_10` INTEGER NOT NULL, `breakHours` INTEGER NOT NULL, FOREIGN KEY (`termCode_id`) REFERENCES `term` (`termCode`), FOREIGN KEY (`department_id`) REFERENCES `department` (`departmentID`), FOREIGN KEY (`approvedBy_id`) REFERENCES `supervisor` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

CREATE UNIQUE INDEX `allocation_termCode_id_department_id_isFinal` ON `allocation` (`termCode_id`, `department_id`, `isFinal`);
64 changes: 31 additions & 33 deletions tests/code/test_adminManagement.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
import pytest
from app.controllers.admin_routes.adminManagement import addAdmin, removeAdmin
from app.models.user import User
from app.models import mainDB
from peewee import DoesNotExist

@pytest.mark.integration
def test_addAdmin():
newAdmin = "pearcej"
user = User.get(User.username == newAdmin)
with mainDB.atomic() as transaction:
newAdmin = "pearcej"
user = User.get(User.username == newAdmin)

# Before adding user as admin
assert not user.isLaborAdmin
# Test adding labor admin
addAdmin(user, 'labor')
assert user.isLaborAdmin
# Before adding user as admin
assert not user.isLaborAdmin
addAdmin(user, 'Labor')
user = User.get(User.username == newAdmin) # check if the db is actually changed
assert user.isLaborAdmin

assert not user.isFinancialAidAdmin
# Test adding financial aid admin
addAdmin(user, 'finAid')
assert user.isFinancialAidAdmin
assert not user.isFinancialAidAdmin
addAdmin(user, 'FinancialAid')
assert user.isFinancialAidAdmin

assert not user.isSaasAdmin
# Test adding saas admin
addAdmin(user, 'saas')
assert user.isSaasAdmin
assert not user.isSaasAdmin
addAdmin(user, 'Saas')
assert user.isSaasAdmin

@pytest.mark.integration
def test_removeAdmin():
oldAdmin = "pearcej"
user = User.get(User.username == oldAdmin)

# Before removing user as admin
assert user.isLaborAdmin
# Test removing labor admin
removeAdmin(user, 'labor')
assert not user.isLaborAdmin

assert user.isFinancialAidAdmin
# Test removing financial aid admin
removeAdmin(user, 'finAid')
assert not user.isFinancialAidAdmin

assert user.isSaasAdmin
# Test removing saas admin
removeAdmin(user, 'saas')
assert not user.isSaasAdmin
with mainDB.atomic() as transaction:
oldAdmin = "pearcej"
user = User.get(User.username == oldAdmin)

assert user.isLaborAdmin
removeAdmin(user, 'Labor')
user = User.get(User.username == oldAdmin) # check if the db is actually changed
assert not user.isLaborAdmin

assert user.isFinancialAidAdmin
removeAdmin(user, 'FinancialAid')
assert not user.isFinancialAidAdmin

assert user.isSaasAdmin
removeAdmin(user, 'Saas')
assert not user.isSaasAdmin
1 change: 1 addition & 0 deletions tests/code/test_apiEndpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_getLaborInformation():
response = getLaborInformation(orgCode = 2114, bNumber="B00841417")

responseData = response.get_json()
print(responseData['B00841417'])
assert responseData['B00841417'][0]['jobType'] == "Primary"
assert responseData['B00841417'][0]['termName'] == "AY 2020-2021"

Expand Down
Loading