diff --git a/app/logic/participants.py b/app/logic/participants.py index c451cdab3..cfa28cc88 100644 --- a/app/logic/participants.py +++ b/app/logic/participants.py @@ -297,10 +297,8 @@ def hasGoneToTraining(participant, term): Event.isAllVolunteerTraining | Event.isCeltsTraining) .order_by(Event.isCeltsTraining) ) - if not attended: return None - if len(attended) > 1: - attended = attended[-1] - return attended.get().event + attended = attended[-1] if len(attended) > 1 else attended[0] + return attended.event diff --git a/app/static/js/userProfile.js b/app/static/js/userProfile.js index acb9ec51c..ddfda7d37 100644 --- a/app/static/js/userProfile.js +++ b/app/static/js/userProfile.js @@ -96,14 +96,13 @@ $(document).ready(function(){ } // This function is to disable all the dates before current date in the ban modal End Date picker - $(function(){ - var banEndDatepicker = $("#banEndDatepicker"); - banEndDatepicker.datepicker({ - changeYear: true, - changeMonth: true, - minDate:+1, - dateFormat: "yy-mm-dd", - }).attr('readonly','readonly'); + $(function () { + const tomorrow = new Date(); + tomorrow.setDate(tomorrow.getDate() + 1); + const year = tomorrow.getFullYear(); + const month = String(tomorrow.getMonth() + 1).padStart(2, "0"); + const day = String(tomorrow.getDate()).padStart(2, "0"); + $("#banEndDatepicker").attr("min",`${year}-${month}-${day}`); }); /* @@ -145,7 +144,14 @@ $(document).ready(function(){ }); $("#banButton").click(function (){ - $("#banButton").prop("disabled", true) + if ($("#banButton").data('banOrUnban') == "Ineligible"){ + const endDateInput = $("#banEndDatepicker")[0]; + if (!endDateInput.checkValidity()) { + endDateInput.reportValidity(); + return; + }; + }; + $("#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"