Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8a298fd
added a transaction.rollback so the form would not be saved
Kafui123 Feb 26, 2026
64e7ca0
further enhanced labor status form creation
Kafui123 Mar 17, 2026
9240ee6
finished working on the flash message confusion
Kafui123 Mar 26, 2026
8df780e
removed all of the print statements
Kafui123 Mar 27, 2026
3ae3aa1
added myself to the test data
Kafui123 Mar 27, 2026
c38d7f4
fixed assertion errors
Kafui123 Mar 31, 2026
9d6e22e
fixed some tests
Kafui123 Mar 31, 2026
ed91c50
fixed some tests
Kafui123 Apr 1, 2026
d60854f
fixed failing tests
Kafui123 Apr 2, 2026
7c0fd6a
Merge remote-tracking branch 'origin' into 526Contrasting_Confirmatio…
Kafui123 Apr 2, 2026
272930d
removed an unused import
Kafui123 Apr 15, 2026
2768210
added an ajax error handler
Kafui123 Apr 15, 2026
5ab735a
changed the test profile to pearcej
Kafui123 Apr 16, 2026
adf5658
put some tests inside a mainDB block
Kafui123 Apr 16, 2026
1091882
Merge branch 'development' into 526Contrasting_Confirmation_Messages
bakobagassas Apr 21, 2026
761b8fb
Merge branch 'development' into 526Contrasting_Confirmation_Messages
MImran2002 Jun 5, 2026
b66b782
Merge branch 'development' into 526Contrasting_Confirmation_Messages
MImran2002 Jun 8, 2026
c84009d
trailing whitespace removed
MImran2002 Jun 8, 2026
c941b9b
made some change
MImran2002 Jun 8, 2026
5b82836
reversing init change
MImran2002 Jun 8, 2026
26c48bf
new changes
MImran2002 Jun 11, 2026
7ae59f0
flash message restored'
MImran2002 Jun 11, 2026
997b0a2
error catching created, front end flash message responsiveness and ov…
MImran2002 Jun 12, 2026
d8b8da8
remove console.log
MImran2002 Jun 12, 2026
06bbba0
Merge branch 'development' into 526Contrasting_Confirmation_Messages
MImran2002 Jun 12, 2026
bd902dc
Merge branch 'development' into 526Contrasting_Confirmation_Messages
MImran2002 Jul 6, 2026
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
28 changes: 16 additions & 12 deletions app/controllers/main_routes/laborStatusForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from app.controllers.main_routes import *
from app.login_manager import require_login
from app.models.user import *
from app.models import mainDB
from app.models.status import *
from app.models.laborStatusForm import *
from app.models.overloadForm import *
Expand Down Expand Up @@ -73,31 +74,34 @@ def userInsert():
rspFunctional = json.loads(rsp)
all_forms = []
for i in range(len(rspFunctional)):

# Get a student record for the given bnumber
try:
student = getOrCreateStudentRecord(bnumber=rspFunctional[i]['stuBNumber'])
supervisor = createSupervisorFromTracy(bnumber=rspFunctional[i]['stuSupervisorID'])
except InvalidUserException as e:
print(e)
return "", 500

department, created = Department.get_or_create(DEPT_NAME = rspFunctional[i]['stuDepartment'])
term, created = Term.get_or_create(termCode = rspFunctional[i]['stuTermCode'])
errorMessage = None
try:
lsf = createLaborStatusForm(student, supervisor.ID, department.departmentID, term, rspFunctional[i])
createOverloadFormAndFormHistory(rspFunctional[i], lsf, currentUser, host=request.host)
try:
emailDuringBreak(checkForSecondLSFBreak(term.termCode, student.ID), term)
except Exception as e:
print("Error when sending emails during break: " + str(e))

with mainDB.atomic():
lsf = createLaborStatusForm(student, supervisor.ID, department.departmentID, term, rspFunctional[i])
try:
createOverloadFormAndFormHistory(rspFunctional[i], lsf, currentUser, host=request.host)
emailDuringBreak(checkForSecondLSFBreak(term.termCode, student.ID), term)
except Exception as e:
errorMessage = "Email(s) delivery failed! Contact support for assistance."
print("ERROR on sending email " + str(e))
raise
all_forms.append(True)
except Exception as e:
all_forms.append(False)
print("ERROR on creating Labor Status Form/Overload Form" + str(e))

flash("Form(s) submitted successfully! They will be eligible for approval in one business day.", "success")
flash(errorMessage, "danger") if errorMessage else None
flash("Form(s) submission failed! Contact support for assistance.", "danger")
print("ERROR on creating Labor Status Form/Overload Form " + str(e))
if all(all_forms):
flash("Form(s) submitted successfully! They will be eligible for approval in one business day.", "success")
return jsonify(all_forms)

@main_bp.route("/laborstatusform/getDate/<termcode>", methods=['GET'])
Expand Down
87 changes: 47 additions & 40 deletions app/logic/statusFormFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,41 +57,43 @@ def createOverloadFormAndFormHistory(rspFunctional, lsf, creatorID, host=None):
"""
# We create a 'Labor Status Form' first, then we check to see if a 'Labor Overload Form'
# needs to be created
isOverload = rspFunctional.get("isItOverloadForm") == "True"
if isOverload:
newLaborOverloadForm = OverloadForm.create( studentOverloadReason = None,
financialAidApproved = None,
financialAidApprover = None,
financialAidReviewDate = None,
SAASApproved = None,
SAASApprover = None,
SAASReviewDate = None,
laborApproved = None,
laborApprover = None,
laborReviewDate = None)
formOverload = FormHistory.create( formID = lsf.laborStatusFormID,
historyType = "Labor Overload Form",
overloadForm = newLaborOverloadForm.overloadFormID,
createdBy = creatorID,
createdDate = date.today(),
status = "Pre-Student Approval")
email = emailHandler(formOverload.formHistoryID)
link = makeThirdPartyLink("student", host, formOverload.formHistoryID)
email.LaborOverLoadFormSubmitted(link)

formHistory = FormHistory.create( formID = lsf.laborStatusFormID,
historyType = "Labor Status Form",
overloadForm = None,
createdBy = creatorID,
createdDate = date.today(),
status = "Pre-Student Approval")

if not formHistory.formID.termCode.isBreak and not isOverload:
email = emailHandler(formHistory.formHistoryID)
email.laborStatusFormSubmitted()
Comment thread
Kafui123 marked this conversation as resolved.
try:
isOverload = rspFunctional.get("isItOverloadForm") == "True"
if isOverload:
newLaborOverloadForm = OverloadForm.create( studentOverloadReason = None,
financialAidApproved = None,
financialAidApprover = None,
financialAidReviewDate = None,
SAASApproved = None,
SAASApprover = None,
SAASReviewDate = None,
laborApproved = None,
laborApprover = None,
laborReviewDate = None)
formOverload = FormHistory.create( formID = lsf.laborStatusFormID,
historyType = "Labor Overload Form",
overloadForm = newLaborOverloadForm.overloadFormID,
createdBy = creatorID,
createdDate = date.today(),
status = "Pre-Student Approval")
email = emailHandler(formOverload.formHistoryID)
link = makeThirdPartyLink("student", host, formOverload.formHistoryID)
email.LaborOverLoadFormSubmitted(link)

return formHistory
formHistory = FormHistory.create( formID = lsf.laborStatusFormID,
historyType = "Labor Status Form",
overloadForm = None,
createdBy = creatorID,
Comment thread
MImran2002 marked this conversation as resolved.
createdDate = date.today(),
status = "Pre-Student Approval")

if not formHistory.formID.termCode.isBreak and not isOverload:
email = emailHandler(formHistory.formHistoryID)
email.laborStatusFormSubmitted()
return formHistory
except Exception as e:
print("Error creating overload form:", e)
raise


def checkForSecondLSFBreak(termCode, student):
Expand Down Expand Up @@ -223,13 +225,18 @@ def emailDuringBreak(secondLSFBreak, term):
"""
Sending emails during break period
"""
if term.isBreak:
isOneLSF = json.loads(secondLSFBreak)
formHistory = FormHistory.get(FormHistory.formHistoryID == isOneLSF['formHistoryID'])
email = emailHandler(formHistory.formHistoryID)
email.laborStatusFormSubmitted()
if(len(isOneLSF["previousSupervisorNames"]) > 1): #Student has more than one lsf. Send email to both supervisors and student
email.notifyAdditionalLaborStatusFormSubmittedForBreak()
try:
if term.isBreak:
isOneLSF = json.loads(secondLSFBreak)
formHistory = FormHistory.get(FormHistory.formHistoryID == isOneLSF['formHistoryID'])
email = emailHandler(formHistory.formHistoryID)
email.laborStatusFormSubmitted()
if(len(isOneLSF["previousSupervisorNames"]) > 1): #Student has more than one lsf. Send email to both supervisors and student
email.notifyAdditionalLaborStatusFormSubmittedForBreak()
except Exception as e:
Comment thread
MImran2002 marked this conversation as resolved.
print("Error sending email during break:", e)
raise



def createOverloadForm(newWeeklyHours, lsf, currentUser, adjustedForm=None, formHistories=None, host=None):
Expand Down
23 changes: 19 additions & 4 deletions app/static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,29 @@ html, body {
}

#flash_container {
position: fixed;
left: 280px;
right: 10px;
z-index: 3;
min-height: 55px;
}

.flash,
#flasher {
margin-bottom: 5px;
position: fixed;
width: 80%;
z-index: 3;
position: relative;
left: 20px;
width: calc(100vw - 320px);;
margin-bottom: 10px;
}

/* When sidebar collapses at the same breakpoint */
@media (max-width: 991px) {
.flash,
#flasher {
left: calc(-280px + 10px);
width: calc(100vw - 20px);
top: 60px;
}
}

.panel {
Expand Down
2 changes: 1 addition & 1 deletion app/static/js/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function msgFlash(flash_message, status){
var category = (status === "success") ? "success" : ((status === "fail") ? "danger" : "warning");
$("#flash_container").prepend('<div class="alert alert-'+ category +'" role="alert" id="flasher">'+flash_message+'</div>');
$("#flash_container").prepend('<div class="alert flash alert-'+ category +'" role="alert" id="flasher">'+flash_message+'</div>');
$("#flasher").delay(5000).fadeOut();
}
117 changes: 47 additions & 70 deletions app/static/js/laborStatusForm.js
Comment thread
Kafui123 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -767,79 +767,56 @@ function userInsert(){
url: "/laborstatusform/userInsert",
data: JSON.stringify(globalArrayOfStudents),
contentType: "application/json",
success: function(response) {
setTimeout(() => {
location.reload();}, 3000);

var isBreak = $('#selectedTerm').find('option:selected').data('termbreak');
modalList = [];
for(var key = 0; key < globalArrayOfStudents.length; key++){
var studentName = globalArrayOfStudents[key].stuName;
var position = globalArrayOfStudents[key].stuPosition;
var selectedContractHours = globalArrayOfStudents[key].stuContractHours;
var jobType = globalArrayOfStudents[key].stuJobType;
var hours = globalArrayOfStudents[key].stuWeeklyHours;

if (response.includes(false)){ // if there is even one false value in response
// var selectedContractHours = globalArrayOfStudents[key].stuWeeklyHours;
if (response[key] === false){ // Finds the form that has failed.
if (isBreak){
display_failed.push(key);
var bigString = "<li>" +"<span class=\"glyphicon glyphicon-remove\" style=\"color:red\"></span> " + studentName + " | " + position + " | " + selectedContractHours + " hours";
}
else {
display_failed.push(key);
var bigString = "<li>"+"<span class=\"glyphicon glyphicon-remove\" style=\"color:red\"></span> " + studentName + " | " + position + " | " + jobType + " | " + hours + " hours";
}
}
else{
if (isBreak){
var bigString = "<li>" +"<span class=\"glyphicon glyphicon-ok\" style=\"color:green\"></span> " + studentName + " | " + position + " | " + selectedContractHours + " hours";
}
else {
var bigString = "<li>"+"<span class=\"glyphicon glyphicon-ok\" style=\"color:green\"></span> " + studentName + " | " + position + " | " + jobType + " | " + hours + " hours";
}
}
modalList.push(bigString);
$("#SubmitModalText").html("Some of your submitted Labor Status Form(s) did not succeed:<br><br>" +
"<ul style=\"list-style-type:none; display: inline-block;text-align:left;\">" +
modalList.join("</li>")+"</ul>"+""
);
$("#closeBtn").hide();
$("#SubmitModal").modal("show");
}
else{
if (isBreak){
var bigString = "<li>" +"<span class=\"glyphicon glyphicon-ok\" style=\"color:green\"></span> " + studentName + " | " + position + " | " + selectedContractHours + " hours";
}
else{
var bigString = "<li>"+"<span class=\"glyphicon glyphicon-ok\" style=\"color:green\"></span> " + studentName + " | " + position + " | " + jobType + " | " + hours + " hours";
}
modalList.push(bigString);
$("#SubmitModalText").html("Labor Status Form(s) succeeded:<br><br>" +
"<ul style=\"list-style-type:none; display: inline-block;text-align:left;\">" +
modalList.join("</li>")+"</ul>"+""
);
$("#closeBtn").hide();
$("#SubmitModal").modal("show");
$("#reviewButton0").prop('disabled',true);
$("#addMoreStudent").prop('disabled',true);
$("a").attr("onclick", "").unbind("click");
$(".glyphicon-edit").css("color", "grey");
$(".glyphicon-remove").css("color", "grey");
parsedArrayOfStudentCookies = document.cookie;
document.cookie = parsedArrayOfStudentCookies +";max-age=0";
window.location.replace("/laborstatusform");
}
}
success: function (response) {
var isBreak = $('#selectedTerm').find('option:selected').data('termbreak');
var hasFailure = response.includes(false);
var hasSuccess = response.includes(true);
modalList = [];
for (var key = 0; key < globalArrayOfStudents.length; key++) {
var studentName = globalArrayOfStudents[key].stuName;
var position = globalArrayOfStudents[key].stuPosition;
var selectedContractHours = globalArrayOfStudents[key].stuContractHours;
var jobType = globalArrayOfStudents[key].stuJobType;
var hours = globalArrayOfStudents[key].stuWeeklyHours;
// build each row
var icon = response[key] === false
? "<span class='glyphicon glyphicon-remove' style='color:red'></span>"
: "<span class='glyphicon glyphicon-ok' style='color:green'></span>";
var bigString;
if (isBreak) {
bigString = `<li>${icon} ${studentName} | ${position} | ${selectedContractHours} hours`;
} else {
bigString = `<li>${icon} ${studentName} | ${position} | ${jobType} | ${hours} hours`;
}
modalList.push(bigString);
}
let message = "";
if (!hasFailure) {
message = "Labor Status Form(s) succeeded:<br><br>";
} else if (hasFailure && hasSuccess) {
message = "Some of your submitted Labor Status Form(s) did not succeed:<br><br>";
} else {
message = "All Labor Status Form(s) failed:<br><br>";
}
$("#SubmitModalText").html(
message +
"<ul style='list-style-type:none; display: inline-block;text-align:left;'>" +
modalList.join("</li>") +
"</ul>"
);
$("#SubmitModal").modal("show");
window.location.replace("/laborstatusform");
},
error: function() {
$('#error_modal').empty();
$('#error_modal').append(
'<p style="padding-left:16px;"><b>ERROR:</b> The request failed. Please try again or contact Systems Support if the issue continues <span style="color:darkred;" class="glyphicon glyphicon-exclamation-sign"></span></p>'
);
msgFlash("Unable to submit the form(s) due to a server or network error.", "fail");
$("#SubmitModal").modal("hide");
$("#submitmodalid").prop("disabled", false);
$("#closeBtn").prop("disabled", false);
$("#submitmodalid").text("Submit");
$("#SubmitModal").data("bs.modal").options.backdrop = true;
$("#SubmitModal").data("bs.modal").options.keyboard = true;

$("#submitmodalid").hide();
$("#doneBtn").show();
}
}); // ajax closing tag

Expand Down
2 changes: 1 addition & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{category}} alert-dismissible" role="alert" id="flasher">{{ message }}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>
<div class="alert alert-{{category}} flash alert-dismissible" role="alert" id="flasher">{{ message }}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>
{% endfor %}
{% endif %}
{% endwith %}
Expand Down
15 changes: 15 additions & 0 deletions database/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@
"LAST_POSN":"TA",
"LAST_SUP_PIDM":"7"
},
{
"ID":"B00791326",
"PIDM":"10",
"FIRST_NAME":"Kafui",
"LAST_NAME":"Gle",
"CLASS_LEVEL":"Junior",
"ACADEMIC_FOCUS":"Computer Science",
"MAJOR":"Computer Science",
"PROBATION":"0",
"ADVISOR":"Jan Pearce",
"STU_EMAIL":"glek@berea.edu",
"STU_CPO":"200",
"LAST_POSN":"TA",
"LAST_SUP_PIDM":"7"
},
]
localStudents = [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/code/test_CreateLSF.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def testCreateLaborStatusForm():
'stuEndDate': "09/01/2020"
}

newlsf = createLaborStatusForm(Student.get_by_id("B00730361"), "B12365892", 1, 202000, lsfDict )
newlsf = createLaborStatusForm(Student.get_by_id("B00730361"), "B12365892", 1, 202500, lsfDict )
lsf = LaborStatusForm.get(LaborStatusForm.laborStatusFormID == newlsf.laborStatusFormID)
assert lsf.termCode_id == 202000
assert lsf.termCode_id == 202500
assert lsf.studentSupervisee_id == "B00730361"
assert lsf.supervisor_id == "B12365892"
assert lsf.department_id == 1
Expand Down
Loading