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 full name to emergency contact updates as well as insurance updates in admin logs (updated) #1247

Closed
wants to merge 7 commits into from
Closed
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
35 changes: 18 additions & 17 deletions app/controllers/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,22 @@ def redirectToLogout():
def landingPage():

managerProgramDict = getManagerProgramDict(g.current_user)

# Optimize the query to fetch programs with non-canceled, non-past events in the current term

programsWithEventsList = list(Program.select(Program, Event)
.join(Event)
.where((Event.term == g.current_term) & (Event.isCanceled == False))
.distinct()
.execute()) # Ensure only unique programs are included
# Limit returned list to events in the future
futureEvents = [p for p in programsWithEventsList if not p.event.isPastEnd]
futureEvents = [p for p in programsWithEventsList if not p.event.isPastEnd]

return render_template("/main/landingPage.html",
managerProgramDict=managerProgramDict,
term=g.current_term,
programsWithEventsList = futureEvents)




@main_bp.route('/goToEventsList/<programID>', methods=['GET'])
def goToEventsList(programID):
return {"activeTab": getActiveEventTab(programID)}
Expand Down Expand Up @@ -188,19 +186,19 @@ def viewUsersProfile(username):
totalSustainedEngagements = totalSustainedEngagements,
)
abort(403)

@main_bp.route('/profile/<username>/emergencyContact', methods=['GET', 'POST'])
###############################EMERGENCY CONTACT######################################
WackyWeaver marked this conversation as resolved.
Show resolved Hide resolved
@main_bp.route('/profile/<username>/emergencyContact', methods=['GET', 'POST'])
def emergencyContactInfo(username):
"""
This loads the Emergency Contact Page
"""
if not (g.current_user.username == username or g.current_user.isCeltsAdmin):
abort(403)

contactInfo = EmergencyContact.get_or_none(EmergencyContact.user_id == username)

if request.method == 'GET':
readOnly = g.current_user.username != username
contactInfo = EmergencyContact.get_or_none(EmergencyContact.user_id == username)
return render_template ("/main/emergencyContactInfo.html",
username=username,
contactInfo=contactInfo,
Expand All @@ -212,16 +210,18 @@ def emergencyContactInfo(username):
abort(403)

rowsUpdated = EmergencyContact.update(**request.form).where(EmergencyContact.user == username).execute()
if not rowsUpdated:

if rowsUpdated:
EmergencyContact.create(user = username, **request.form)
createActivityLog(f"{g.current_user} updated {username}'s emergency contact information.")

createActivityLog(f"{g.current_user.fullName} updated {contactInfo.user.fullName}'s emergency contact information.")
flash('Emergency contact information saved successfully!', 'success')

if request.args.get('action') == 'exit':
return redirect (f"/profile/{username}")
else:
return redirect (f"/profile/{username}/insuranceInfo")

###############################INSURANCE INFO######################################
WackyWeaver marked this conversation as resolved.
Show resolved Hide resolved
@main_bp.route('/profile/<username>/insuranceInfo', methods=['GET', 'POST'])
def insuranceInfo(username):
"""
Expand All @@ -230,9 +230,10 @@ def insuranceInfo(username):
if not (g.current_user.username == username or g.current_user.isCeltsAdmin):
abort(403)

userInsuranceInfo = InsuranceInfo.get_or_none(InsuranceInfo.user_id == username)

if request.method == 'GET':
readOnly = g.current_user.username != username
userInsuranceInfo = InsuranceInfo.get_or_none(InsuranceInfo.user == username)
return render_template ("/main/insuranceInfo.html",
username=username,
userInsuranceInfo=userInsuranceInfo,
Expand All @@ -245,16 +246,18 @@ def insuranceInfo(username):
abort(403)

rowsUpdated = InsuranceInfo.update(**request.form).where(InsuranceInfo.user == username).execute()
if not rowsUpdated:

if rowsUpdated:
InsuranceInfo.create(user = username, **request.form)
createActivityLog(f"{g.current_user} updated {username}'s emergency contact information.")

createActivityLog(f"{g.current_user.fullName} updated { userInsuranceInfo.user.fullName}'s insurance information.")
flash('Insurance information saved successfully!', 'success')

if request.args.get('action') == 'exit':
return redirect (f"/profile/{username}")
else:
return redirect (f"/profile/{username}/emergencyContact")

###############################TRAVEL FORM######################################
@main_bp.route('/profile/<username>/travelForm', methods=['GET', 'POST'])
def travelForm(username):
if not (g.current_user.username == username or g.current_user.isCeltsAdmin):
Expand All @@ -272,8 +275,7 @@ def travelForm(username):
return render_template ('/main/travelForm.html',
userData = userData
)


###############################PROFILE NOTES######################################
@main_bp.route('/profile/addNote', methods=['POST'])
def addNote():
"""
Expand Down Expand Up @@ -346,7 +348,6 @@ def unban(program_id, username):
flash("Failed to unban the volunteer", "danger")
return "Failed to unban the volunteer", 500


@main_bp.route('/<username>/addInterest/<program_id>', methods=['POST'])
def addInterest(program_id, username):
"""
Expand Down
2 changes: 1 addition & 1 deletion app/logic/createLogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def createRsvpLog(eventId, content):
date = datetime.now()
EventRsvpLog.create(createdBy=g.current_user,createdOn=date,rsvpLogContent=content,event_id=eventId)


def createActivityLog(content):
date = datetime.now()
ActivityLog.create(createdBy=g.current_user,createdOn=date,logContent=content)

1 change: 0 additions & 1 deletion app/models/activityLog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from app.models import*
from app.models.user import User

Expand Down
2 changes: 1 addition & 1 deletion app/models/emergencyContact.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from app.models.user import User

class EmergencyContact(baseModel):
user = ForeignKeyField(User)
user = ForeignKeyField(User, unique=True)
name = CharField(default='')
relationship = CharField(default='')
homePhone = CharField(default='')
Expand Down
1 change: 0 additions & 1 deletion app/static/js/emergencyContactInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ $(document).ready(function(){
return e;
}
});

return invalidInputs.length == 0;
}
});
10 changes: 5 additions & 5 deletions app/static/js/insuranceInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ $(document).ready(function(){

function formIsValid(){
let invalidInputs = $('input').map(function(i, e){
if (! e.checkValidity()) {
e.reportValidity()
return e
if (!e.checkValidity()) {
e.reportValidity();
return e;
}
})
return invalidInputs.length == 0
});
return invalidInputs.length == 0;
}
});
Loading