Skip to content
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

added button for resubmitting forms to banner #427

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
29 changes: 29 additions & 0 deletions app/controllers/admin_routes/allPendingForms.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,35 @@ def finalUpdateStatus(raw_status):
form_ids = eval(request.data.decode("utf-8"))
return saveStatus(new_status, form_ids, currentUser)

@admin.route('/admin/addToBanner/<form_id>', methods=['POST'])
def submitToBanner(form_id):
''' This method adds a form to Banner if it's already approved '''
currentUser = require_login()
if not currentUser: # Not logged in
return render_template('errors/403.html'), 403
if not currentUser.isLaborAdmin: # Not an admin
return render_template('errors/403.html'), 403

try:
form_history = FormHistory.get(FormHistory.formID == int(form_id))

# Add to Banner only if the form is approved
if form_history.status.statusName == "Approved":
history_type = str(form_history.historyType)
labor_form = FormHistory.get(FormHistory.formID == int(form_id), FormHistory.historyType == history_type)

conn = Banner()

Choose a reason for hiding this comment

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

what does conn stand for? could you rename it so that it correlates to the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

conn stands for Bonner connection, it is used in another function, wanted to keep it consistent

save_status = conn.insert(labor_form)
if save_status:
return jsonify({"success": True})
else:
return jsonify({"success": False}), 500
else:
return jsonify({"success": False})
except Exception as e:
print("Error adding form to Banner:", e)
return jsonify({"success": False}), 500

def saveStatus(new_status, form_ids, currentUser):
try:
if new_status == 'Denied':
Expand Down
20 changes: 20 additions & 0 deletions app/static/js/allPendingForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,26 @@ function finalApproval() { //this method changes the status of the lsf from pend
});
}

function studentHistoryModalClose(){
modal.style.display = "none";
}

function submitToBanner(formId) {
$.ajax({
type: "POST",
url: "/admin/addToBanner/" + formId,
success: function(response) {
if (response.success) {
msgFlash("Form submitted to banner successfully ", "success");
studentHistoryModalClose();
} else {
msgFlash("Form failed to submit to banner", "fail");
studentHistoryModalClose();
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider leaving the modal open to accept changes when the ajax fails. when you close it when it fails, it requires the user to open the modal again. Since there are three different fail conditions, it might be useful to have a more descriptive fail reason for the user.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the modal is not closed after failure, the flash message saying that if failed to submit won't appear.

}
}
});
}

var laborDenialInfo = []; //this arrary is for insertDenial() and finalDenial() methods
//This method calls AJAX from checkforms methods in the controller
function insertDenial(val) {
Expand Down
6 changes: 5 additions & 1 deletion app/templates/snips/studentHistoryModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,13 @@
</a>
</div>
{% endif %}
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="submitToBanner({{statusForm.laborStatusFormID}})">Submit to Banner</button>
{% endif %}



</div>




</div>