Skip to content

Commit

Permalink
Anna, removeFromTranscript status can now be saved into the table as …
Browse files Browse the repository at this point in the history
…a program is banned and no longer requires a program to first be banned and having to go into unban modal
  • Loading branch information
vungc authored Nov 6, 2024
1 parent 6530720 commit f0fde03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/controllers/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,9 @@ def ban(program_id, username):
postData = request.form
banNote = postData["note"] # This contains the note left about the change
banEndDate = postData["endDate"] # Contains the date the ban will no longer be effective
toRemoveFromTranscript = postData["removeFromTranscript"] =='true'
try:
banUser(program_id, username, banNote, banEndDate, g.current_user)
banUser(program_id, username, banNote, banEndDate, toRemoveFromTranscript, g.current_user)
programInfo = Program.get(int(program_id))
flash("Successfully banned the volunteer", "success")
createActivityLog(f'Banned {username} from {programInfo.programName} until {banEndDate}.')
Expand Down
6 changes: 4 additions & 2 deletions app/logic/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def isBannedFromEvent(username, eventId):
user = User.get(User.username == username)
return not isEligibleForProgram(program, user)

def banUser(program_id, username, note, banEndDate, creator):
def banUser(program_id, username, note, banEndDate, toRemoveFromTranscript, creator):
"""
This function creates an entry in the note table and programBan table in order
to ban the selected user.
Expand All @@ -77,6 +77,7 @@ def banUser(program_id, username, note, banEndDate, creator):
banEndDate: date when the ban will end
creator: the admin or person with authority who created the ban
"""

noteForDb = Note.create(createdBy = creator,
createdOn = datetime.datetime.now(),
noteContent = note,
Expand All @@ -86,7 +87,8 @@ def banUser(program_id, username, note, banEndDate, creator):
ProgramBan.create(program = program_id,
user = username,
endDate = banEndDate,
banNote = noteForDb)
banNote = noteForDb,
removeFromTranscript = toRemoveFromTranscript)

def unbanUser(program_id, username, note, creator):
"""
Expand Down
5 changes: 4 additions & 1 deletion app/static/js/userProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,14 @@ $(document).ready(function(){
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"
var program = $(this).data("programID") //Expected to be a program's primary ID
var removeFromTranscriptState = $("#removeFromTranscriptCheckbox").is(':checked');

$.ajax({
method: "POST",
url: "/" + username + "/" + route + "/" + program,
data: {"note": $("#banNoteTxtArea").val(),
"endDate":$("#banEndDatepicker").val() //Expected to be a date in this format YYYY-MM-DD
"endDate":$("#banEndDatepicker").val(), //Expected to be a date in this format YYYY-MM-DD
"removeFromTranscript": removeFromTranscriptState
},
success: function(response) {
reloadWithAccordion("programTable")
Expand Down

0 comments on commit f0fde03

Please sign in to comment.