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
20 changes: 10 additions & 10 deletions app/controllers/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,13 @@ def ban(program_id, username):
try:
banUser(program_id, username, banNote, banEndDate, g.current_user)
programInfo = Program.get(int(program_id))
flash("Successfully banned the volunteer", "success")
createActivityLog(f'Banned {username} from {programInfo.programName} until {banEndDate}.')
return "Successfully banned the volunteer."
flash("Successfully marked the volunteer as ineligible", "success")
createActivityLog(f'Marked {username} as ineligible from {programInfo.programName} until {banEndDate}.')
return "Successfully marked the volunteer as ineligible."
except Exception as e:
print("Error while updating ban", e)
flash("Failed to ban the volunteer", "danger")
return "Failed to ban the volunteer", 500
flash("Failed to mark the volunteer as ineligible", "danger")
return "Failed to mark the volunteer as ineligible", 500

# ===========================Unban===============================================
@main_bp.route('/<username>/unban/<program_id>', methods=['POST'])
Expand All @@ -443,14 +443,14 @@ def unban(program_id, username):
try:
unbanUser(program_id, username, unbanNote, g.current_user)
programInfo = Program.get(int(program_id))
createActivityLog(f'Unbanned {username} from {programInfo.programName}.')
flash("Successfully unbanned the volunteer", "success")
return "Successfully unbanned the volunteer"
createActivityLog(f'marked {username} as eligible from {programInfo.programName}.')
flash("Successfully marked the volunteer as eligible", "success")
return "Successfully marked the volunteer as eligible"

except Exception as e:
print("Error while updating Unban", e)
flash("Failed to unban the volunteer", "danger")
return "Failed to unban the volunteer", 500
flash("Failed to mark the volunteer as eligible", "danger")
return "Failed to mark the volunteer as eligible", 500


@main_bp.route('/<username>/addInterest/<program_id>', methods=['POST'])
Expand Down
12 changes: 9 additions & 3 deletions app/static/js/userProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ $(document).ready(function(){
var banNote = $("#banNote")
var banValue = $(this).val()

banButton.text(banValue + " Volunteer");
banButton.text("Set " + banValue);
programID = $(this).data("programid"); // Assign value to programID variable
banButton.data("programID", programID)
banButton.data("username", $(".banEdit").data("username"))
banButton.data("banOrUnban", banValue);
banEndDateDiv.show();
banEndDatepicker.val("")
$(".modal-title-ban").text(banValue + " Volunteer from "+ $(this).data("name") + "?");
$(".modal-title-ban").text("Mark Volunteer as " + banValue + " from "+ $(this).data("name") + "?");
$("#modalProgramName").text("Program: " + $(this).data("name"));
$("#banModal").modal("toggle");
$("#banNoteTxtArea").val("");
$("#banButton").prop("disabled", true);
if(banValue == "Unban"){
if(banValue == "Eligible"){
banEndDateDiv.hide()
banEndDatepicker.val("0001-01-01") //This is a placeholder value for the if statement in line 52 to work properly #PLCHLD1
banNoteDiv.show()
Expand All @@ -143,6 +143,12 @@ $(document).ready(function(){
$("#banButton").prop("disabled", true)
var username = $(this).data("username") //Expected to be the unique username of a user in the database
var route = ($(this).data("banOrUnban")).toLowerCase() //Expected to be "ban" or "unban"

if(route =="eligible"){ // This handles the case where the user is being marked as eligible/ineligible and changes to ban and unban status for the route
route= 'unban'
}else{
route= 'ban'
}
var program = $(this).data("programID") //Expected to be a program's primary ID

$.ajax({
Expand Down
12 changes: 6 additions & 6 deletions app/templates/main/userProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ <h3 class="accordion-header" id="headingThree">
{% if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentStaff %}
{% if row.isNotBanned %}
<td class="programBan pt-3"> Eligible
{% set label = "Ban" %}
{% set label = "Ineligible" %}
{% else %}
<td class="programBan text-danger pt-3"> Banned
{% set label = "Unban" %}
<td class="programBan text-danger pt-3"> Ineligible
{% set label = "Eligible" %}
{% endif %}

{% if g.current_user.isCeltsAdmin %}
Expand Down Expand Up @@ -639,8 +639,8 @@ <h6 align="left">Full Name: {{volunteer.firstName}} {{volunteer.lastName}} </h6>
<h6 align="left">Email Address: {{volunteer.email}}</h6>
<h6 align="left">Phone Number: <a href="tel:{{volunteer.phoneNumber}}">{{volunteer.phoneNumber}}</a></h6>
<div id="banNoteDiv">
<h6 align="left">Reason for ban:</h6>
<p align="left" id="banNote">Why the student was banned</p>
<h6 align="left">Reason for ineligibility:</h6>
<p align="left" id="banNote">Why the student is ineligible</p>
</div>
<div id="banEndDate">
<h6 align="left" class="d-inline-flex" id="unbanVolunteerEndDate">End Date: &nbsp<input id="banEndDatepicker" type="date"></h6><span class="text-danger">*</span>
Expand All @@ -654,7 +654,7 @@ <h6 align="left" class="d-inline-flex" id="unbanVolunteerEndDate">End Date: &nbs
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button id="banButton" type="button" class="btn btn-danger" data-banOrUnban="" >Ban/Unban Volunteer</button>
<button id="banButton" type="button" class="btn btn-danger" data-banOrUnban="" >Mark Ineligible/Eligible</button>
</div>
</div>
</div>
Expand Down
Loading