diff --git a/app/controllers/admin/routes.py b/app/controllers/admin/routes.py index b7d0b52b7..4717b0909 100644 --- a/app/controllers/admin/routes.py +++ b/app/controllers/admin/routes.py @@ -5,6 +5,7 @@ import json from datetime import datetime import os +from typing import List from app import app from app.models.program import Program @@ -44,17 +45,16 @@ def switchUser(): print(f"Switching user from {g.current_user} to",request.form['newuser']) session['current_user'] = model_to_dict(User.get_by_id(request.form['newuser'])) - return redirect(request.referrer) @admin_bp.route('/eventTemplates') -def templateSelect(): - if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentStaff: - allprograms = getAllowedPrograms(g.current_user) - visibleTemplates = getAllowedTemplates(g.current_user) +def templateSelect() -> str: + if g.current_user.isAdmin: + allowedPrograms: List[Program] = getAllowedPrograms(g.current_user) + visibleTemplates: List[EventTemplate] = getAllowedTemplates(g.current_user) return render_template("/events/template_selector.html", - programs=allprograms, + programs=allowedPrograms, celtsSponsoredProgram = Program.get(Program.isOtherCeltsSponsored), templates=visibleTemplates) else: @@ -143,16 +143,17 @@ def createEvent(templateid, programid): @admin_bp.route('/event//rsvp', methods=['GET']) -def rsvpLogDisplay(eventId): - event = Event.get_by_id(eventId) - if g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerFor(event.program)): - allLogs = EventRsvpLog.select(EventRsvpLog, User).join(User).where(EventRsvpLog.event_id == eventId).order_by(EventRsvpLog.createdOn.desc()) - return render_template("/events/rsvpLog.html", - event = event, - allLogs = allLogs) - else: +def rsvpLogDisplay(eventId: int) -> str: + event: Event = Event.get_by_id(eventId) + + canAccessProgram: bool = event.program in getAllowedPrograms(g.current_user) + if not canAccessProgram: abort(403) + allLogs: List[(EventRsvpLog, User)] = EventRsvpLog.select(EventRsvpLog, User).join(User).where(EventRsvpLog.event_id == eventId).order_by(EventRsvpLog.createdOn.desc()) + return render_template("/events/rsvpLog.html", + event = event, + allLogs = allLogs) @admin_bp.route('/event//view', methods=['GET']) @admin_bp.route('/event//edit', methods=['GET','POST']) @@ -168,8 +169,7 @@ def eventDisplay(eventId): except DoesNotExist as e: print(f"Unknown event: {eventId}") abort(404) - - notPermitted = not (g.current_user.isCeltsAdmin or g.current_user.isProgramManagerForEvent(event)) + notPermitted = not (event.program in getAllowedPrograms(g.current_user) or (g.current_user.isCeltsStudentAdmin and event.programName != "Bonner Scholars")) if 'edit' in request.url_rule.rule and notPermitted: abort(403) diff --git a/app/controllers/admin/userManagement.py b/app/controllers/admin/userManagement.py index 80239f5fd..8069bd063 100644 --- a/app/controllers/admin/userManagement.py +++ b/app/controllers/admin/userManagement.py @@ -1,78 +1,69 @@ from flask import render_template,request, flash, g, abort, redirect, url_for import re +from typing import Dict, Any, List from app.controllers.admin import admin_bp from app.models.user import User from app.models.program import Program -from app.logic.userManagement import addCeltsAdmin,addCeltsStudentStaff,removeCeltsAdmin,removeCeltsStudentStaff +from app.models.term import Term +from app.logic.userManagement import addCeltsAdmin,addCeltsStudentStaff,addCeltsStudentAdmin ,removeCeltsAdmin,removeCeltsStudentStaff, removeCeltsStudentAdmin from app.logic.userManagement import changeProgramInfo from app.logic.utils import selectSurroundingTerms from app.logic.term import addNextTerm, changeCurrentTerm @admin_bp.route('/admin/manageUsers', methods = ['POST']) -def manageUsers(): - eventData = request.form - user = eventData['user'] - method = eventData['method'] - username = re.sub("[()]","", (user.split())[-1]) +def manageUsers() -> str: + eventData: Dict[str, str] = request.form + user: str = eventData['user'] + method: str = eventData['method'] + username: str = re.sub("[()]","", (user.split())[-1]) try: - user = User.get_by_id(username) + user: User = User.get_by_id(username) except Exception as e: print(e) flash(username + " is an invalid user.", "danger") return ("danger", 500) if method == "addCeltsAdmin": - if user.isStudent and not user.isCeltsStudentStaff: - flash(user.firstName + " " + user.lastName + " cannot be added as a CELTS-Link admin", 'danger') - else: - if user.isCeltsAdmin: - flash(user.firstName + " " + user.lastName + " is already a CELTS-Link Admin", 'danger') - else: - addCeltsAdmin(user) - flash(user.firstName + " " + user.lastName + " has been added as a CELTS-Link Admin", 'success') + try: + addCeltsAdmin(user) + flash(f"{user.fullName} has been added as CELTS Admin.", 'success') + except Exception as errorMessage: + flash(str(errorMessage), 'danger') + elif method == "addCeltsStudentStaff": - if not user.isStudent: - flash(username + " cannot be added as CELTS Student Staff", 'danger') - else: - if user.isCeltsStudentStaff: - flash(user.firstName + " " + user.lastName + " is already a CELTS Student Staff", 'danger') - else: - addCeltsStudentStaff(user) - flash(user.firstName + " " + user.lastName + " has been added as a CELTS Student Staff", 'success') + try: + addCeltsStudentStaff(user) + flash(f"{user.fullName} has been added as CELTS Student Staff.", 'success') + except Exception as errorMessage: + flash(str(errorMessage), "danger") + + elif method == "addCeltsStudentAdmin": + try: + addCeltsStudentAdmin(user) + flash(f"{user.fullName} has been added as CELTS Student Admin.", 'success') + except Exception as errorMessage: + flash(str(errorMessage), "danger") + elif method == "removeCeltsAdmin": removeCeltsAdmin(user) - flash(user.firstName + " " + user.lastName + " is no longer a CELTS Admin ", 'success') + flash(f"{user.fullName} is no longer a CELTS Admin.", 'success') + elif method == "removeCeltsStudentStaff": removeCeltsStudentStaff(user) - flash(user.firstName + " " + user.lastName + " is no longer a CELTS Student Staff", 'success') - return ("success") + flash(f"{user.fullName} is no longer a CELTS Student Staff.", 'success') -@admin_bp.route('/addProgramManagers', methods=['POST']) -def addProgramManagers(): - eventData = request.form - try: - return addProgramManager(eventData['username'],int(eventData['programID'])) - except Exception as e: - print(e) - flash('Error while trying to add a manager.','warning') - abort(500,"'Error while trying to add a manager.'") + elif method == "removeCeltsStudentAdmin": + removeCeltsStudentAdmin(user) + flash(f"{user.fullName} is no longer a CELTS Student Admin.", 'success') -@admin_bp.route('/removeProgramManagers', methods=['POST']) -def removeProgramManagers(): - eventData = request.form - try: - return removeProgramManager(eventData['username'],int(eventData['programID'])) - except Exception as e: - print(e) - flash('Error while removing a manager.','warning') - abort(500,"Error while trying to remove a manager.") + return ("success") @admin_bp.route('/admin/updateProgramInfo/', methods=['POST']) -def updateProgramInfo(programID): +def updateProgramInfo(programID: int) -> Any: """Grabs info and then outputs it to logic function""" - programInfo = request.form # grabs user inputs - if g.current_user.isCeltsAdmin: + programInfo: Dict[str, str] = request.form # grabs user inputs + if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin: try: changeProgramInfo(programInfo["programName"], #calls logic function to add data to database programInfo["contactEmail"], @@ -89,17 +80,19 @@ def updateProgramInfo(programID): abort(403) @admin_bp.route('/admin', methods = ['GET']) -def userManagement(): - terms = selectSurroundingTerms(g.current_term) - current_programs = Program.select() - currentAdmins = list(User.select().where(User.isCeltsAdmin)) - currentStudentStaff = list(User.select().where(User.isCeltsStudentStaff)) - if g.current_user.isCeltsAdmin: +def userManagement() -> str: + terms: List[Term] = selectSurroundingTerms(g.current_term) + currentPrograms: List[Program] = list(Program.select()) + currentAdmins: List[User] = list(User.select().where(User.isCeltsAdmin)) + currentStudentStaff: List[User] = list(User.select().where(User.isCeltsStudentStaff)) + currentStudentAdmin: List[User] = list(User.select().where(User.isCeltsStudentAdmin)) + if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin: return render_template('admin/userManagement.html', terms = terms, - programs = list(current_programs), + programs = currentPrograms, currentAdmins = currentAdmins, currentStudentStaff = currentStudentStaff, + currentStudentAdmin = currentStudentAdmin, ) abort(403) diff --git a/app/controllers/admin/volunteers.py b/app/controllers/admin/volunteers.py index 8634cd07a..4da3ff1e6 100644 --- a/app/controllers/admin/volunteers.py +++ b/app/controllers/admin/volunteers.py @@ -1,12 +1,16 @@ from flask import request, render_template, redirect, url_for, flash, abort, g, json, jsonify from peewee import DoesNotExist, JOIN from playhouse.shortcuts import model_to_dict +from typing import List + from app.controllers.admin import admin_bp from app.models.event import Event from app.models.program import Program from app.models.user import User from app.models.eventParticipant import EventParticipant from app.models.emergencyContact import EmergencyContact + +from app.logic.userManagement import getAllowedPrograms from app.logic.searchUsers import searchUsers from app.logic.volunteers import updateEventParticipants, getEventLengthInHours, addUserBackgroundCheck, setProgramManager from app.logic.participants import trainedParticipants, addPersonToEvent, getParticipationStatusForTrainings, sortParticipantsByStatus @@ -18,13 +22,13 @@ @admin_bp.route('/searchVolunteers/', methods = ['GET']) -def getVolunteers(query): +def getVolunteers(query: str) -> str: '''Accepts user input and queries the database returning results that matches user search''' return json.dumps(searchUsers(query)) @admin_bp.route('/event//manage_volunteers', methods=['GET', 'POST']) -def manageVolunteersPage(eventID): +def manageVolunteersPage(eventID) -> str: """ Controller that handles POST and GET requests regarding the Manage Volunteers page. @@ -36,14 +40,14 @@ def manageVolunteersPage(eventID): renders the manageVolunteers.html template. """ try: - event = Event.get_by_id(eventID) + event: Event = Event.get_by_id(eventID) except DoesNotExist as e: print(f"No event found for {eventID}", e) abort(404) # ------------ POST request ------------ if request.method == "POST": - volunteerUpdated = updateEventParticipants(request.form) + volunteerUpdated: bool = updateEventParticipants(request.form) # error handling depending on the boolean returned from updateEventParticipants if volunteerUpdated: @@ -53,54 +57,55 @@ def manageVolunteersPage(eventID): return redirect(url_for("admin.manageVolunteersPage", eventID=eventID)) # ------------ GET request ------------ - elif request.method == "GET": - if not (g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerForEvent(event))): - abort(403) - - # ------- Grab the different lists of participants ------- - trainedParticipantsForProgramAndTerm = trainedParticipants(event.program, event.term) - - bannedUsersForProgram = [bannedUser.user for bannedUser in getBannedUsers(event.program)] - - eventNonAttendedData, eventWaitlistData, eventVolunteerData, eventParticipants = sortParticipantsByStatus(event) - - allRelevantUsers = [participant.user for participant in (eventParticipants + eventNonAttendedData + eventWaitlistData)] - - # ----------- Get miscellaneous data ----------- - - participationStatusForTrainings = getParticipationStatusForTrainings(event.program, allRelevantUsers, event.term) - - eventLengthInHours = getEventLengthInHours(event.timeStart, event.timeEnd, event.startDate) - - recurringVolunteers = getPreviousRecurringEventData(event.recurringId) - - currentRsvpAmount = getEventRsvpCount(event.id) - - # ----------- Render template with all of the data ------------ - return render_template("/events/manageVolunteers.html", - eventVolunteerData = eventVolunteerData, - eventNonAttendedData = eventNonAttendedData, - eventWaitlistData = eventWaitlistData, - eventLength = eventLengthInHours, - event = event, - recurringVolunteers = recurringVolunteers, - bannedUsersForProgram = bannedUsersForProgram, - trainedParticipantsForProgramAndTerm = trainedParticipantsForProgramAndTerm, - participationStatusForTrainings = participationStatusForTrainings, - currentRsvpAmount = currentRsvpAmount) + canAccessProgram: bool = event.program in getAllowedPrograms(g.current_user) + if not canAccessProgram: + abort(403) + + # ------- Grab the different lists of participants ------- + trainedParticipantsForProgramAndTerm: List[User] = trainedParticipants(event.program, event.term) + + bannedUsersForProgram: List[User] = [bannedUser.user for bannedUser in getBannedUsers(event.program)] + + eventNonAttendedData, eventWaitlistData, eventVolunteerData, eventParticipants = sortParticipantsByStatus(event) + + allRelevantUsers = [participant.user for participant in (eventParticipants + eventNonAttendedData + eventWaitlistData)] + + # ----------- Get miscellaneous data ----------- + + participationStatusForTrainings = getParticipationStatusForTrainings(event.program, allRelevantUsers, event.term) + + eventLengthInHours: float = getEventLengthInHours(event.timeStart, event.timeEnd, event.startDate) + + recurringVolunteers = getPreviousRecurringEventData(event.recurringId) + + currentRsvpAmount: int = getEventRsvpCount(event.id) + + # ----------- Render template with all of the data ------------ + + return render_template("/events/manageVolunteers.html", + eventVolunteerData = eventVolunteerData, + eventNonAttendedData = eventNonAttendedData, + eventWaitlistData = eventWaitlistData, + eventLength = eventLengthInHours, + event = event, + recurringVolunteers = recurringVolunteers, + bannedUsersForProgram = bannedUsersForProgram, + trainedParticipantsForProgramAndTerm = trainedParticipantsForProgramAndTerm, + participationStatusForTrainings = participationStatusForTrainings, + currentRsvpAmount = currentRsvpAmount) @admin_bp.route('/event//volunteer_details', methods=['GET']) -def volunteerDetailsPage(eventID): +def volunteerDetailsPage(eventID) -> str: try: - event = Event.get_by_id(eventID) + event: Event = Event.get_by_id(eventID) except DoesNotExist as e: print(f"No event found for {eventID}", e) abort(404) - - if not (g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerForEvent(event))): + canAccessProgram: bool = event.program in getAllowedPrograms(g.current_user) + if not (canAccessProgram): abort(403) - eventRsvpData = list(EventRsvp.select(EmergencyContact, EventRsvp) + eventRsvpData: List = list(EventRsvp.select(EmergencyContact, EventRsvp) .join(EmergencyContact, JOIN.LEFT_OUTER, on=(EmergencyContact.user==EventRsvp.user)) .where(EventRsvp.event==event)) eventParticipantData = list(EventParticipant.select(EmergencyContact, EventParticipant) diff --git a/app/logic/participants.py b/app/logic/participants.py index fecf94506..b8cd50606 100644 --- a/app/logic/participants.py +++ b/app/logic/participants.py @@ -1,6 +1,8 @@ from flask import g from peewee import fn, JOIN from datetime import date +from typing import List + from app.models.user import User from app.models.event import Event from app.models.term import Term @@ -12,7 +14,7 @@ from app.logic.events import getEventRsvpCountsForTerm from app.logic.createLogs import createRsvpLog -def trainedParticipants(programID, targetTerm): +def trainedParticipants(programID: int, targetTerm: Term) -> List[User]: """ This function tracks the users who have attended every Prerequisite event and adds them to a list that will not flag them when tracking hours. @@ -20,14 +22,14 @@ def trainedParticipants(programID, targetTerm): """ # Reset program eligibility each term for all other trainings - isRelevantAllVolunteer = (Event.isAllVolunteerTraining) & (Event.term.academicYear == targetTerm.academicYear) - isRelevantProgramTraining = (Event.program == programID) & (Event.term == targetTerm) & (Event.isTraining) - allTrainings = (Event.select() + isRelevantAllVolunteer: bool = (Event.isAllVolunteerTraining) & (Event.term.academicYear == targetTerm.academicYear) + isRelevantProgramTraining: bool = (Event.program == programID) & (Event.term == targetTerm) & (Event.isTraining) + allTrainings: List[Event] = (Event.select() .join(Term) .where(isRelevantAllVolunteer | isRelevantProgramTraining, Event.isCanceled == False)) - fullyTrainedUsers = (User.select() + fullyTrainedUsers: List[User] = (User.select() .join(EventParticipant) .where(EventParticipant.event.in_(allTrainings)) .group_by(EventParticipant.user) diff --git a/app/logic/userManagement.py b/app/logic/userManagement.py index c4ee88d0c..7396fe440 100644 --- a/app/logic/userManagement.py +++ b/app/logic/userManagement.py @@ -3,47 +3,72 @@ from app.models.programManager import ProgramManager from app.models.program import Program from app.models.eventTemplate import EventTemplate -from flask import g, session +from flask import g, session, flash from app.logic.createLogs import createAdminLog from playhouse.shortcuts import model_to_dict +from typing import List -def addCeltsAdmin(user): - user = User.get_by_id(user) - user.isCeltsAdmin = True - user.save() - createAdminLog(f'Made {user.firstName} {user.lastName} a CELTS admin member.') - +def addCeltsAdmin(user: str) -> None: + if user.isCeltsAdmin: + raise Exception(f"{user.fullName} is already a CELTS Admin.") + elif user.isStudent and not user.isCeltsStudentStaff: + raise Exception(f"{user.fullName} cannot be added as CELTS Admin.") + else: + user: User = User.get_by_id(user) + user.isCeltsAdmin = True + user.save() + createAdminLog(f'Made f"{user.fullName} a CELTS admin member.') -def addCeltsStudentStaff(user): - user = User.get_by_id(user) - user.isCeltsStudentStaff = True - user.save() - createAdminLog(f'Made {user.firstName} {user.lastName} a CELTS student staff member.') +def addCeltsStudentStaff(user: str) -> None: + if user.isCeltsStudentStaff: + raise Exception(f"{user.fullName} is already a CELTS Student Staff.") + elif user.isStudent: + user: User = User.get_by_id(user) + user.isCeltsStudentStaff = True + user.save() + createAdminLog(f'Made f"{user.fullName} a CELTS Student Staff.') + else: + raise Exception(f"{user.fullName} cannot be added as CELTS Student Staff.") + +def addCeltsStudentAdmin(user: str) -> None: + if user.isCeltsStudentAdmin: + raise Exception(f"{user.fullName} is already a CELTS Student Admin.") + elif user.isStudent: + user: User = User.get_by_id(user) + user.isCeltsStudentAdmin = True + user.save() + createAdminLog(f'Made {user.fullName} a CELTS Student Admin.') + else: + raise Exception(f"{user.fullName} cannot be added as CELTS Student Admin.") + -def removeCeltsAdmin(user): - user = User.get_by_id(user) +def removeCeltsAdmin(user: str) -> None: + user: User = User.get_by_id(user) user.isCeltsAdmin = False user.save() - createAdminLog(f'Removed {user.firstName} {user.lastName} from CELTS admins.') - - -def removeCeltsStudentStaff(user): - user = User.get_by_id(user) - programManagerRoles = list([obj.program.programName for obj in ProgramManager.select(Program).join(Program).where(ProgramManager.user == user)]) - programManagerRoles = ", ".join(programManagerRoles) + createAdminLog(f'Removed f"{user.fullName} from CELTS admins.') + +def removeCeltsStudentStaff(user: str) -> None: + user: User = User.get_by_id(user) + programManagerRoles: List[str] = list([obj.program.programName for obj in ProgramManager.select(Program).join(Program).where(ProgramManager.user == user)]) + programManagerRoles: str = ", ".join(programManagerRoles) ProgramManager.delete().where(ProgramManager.user_id == user).execute() user.isCeltsStudentStaff = False user.save() createAdminLog(f'Removed {user.firstName} {user.lastName} from a CELTS student staff member'+ (f', and as a manager of {programManagerRoles}.' if programManagerRoles else ".")) +def removeCeltsStudentAdmin(user: str) -> None: + user: User = User.get_by_id(user) + user.isCeltsStudentAdmin = False + user.save() + createAdminLog(f'Removed f"{user.fullName} from a CELTS student admins.') -def changeProgramInfo(newProgramName, newContactEmail, newContactName, newLocation, programId): +def changeProgramInfo(newProgramName: str, newContactEmail: str, newContactName: str, newLocation: str, programId: int) -> str: """Updates the program info with a new sender and email.""" - program = Program.get_by_id(programId) - updatedProgram = Program.update({Program.programName:newProgramName, Program.contactEmail: newContactEmail, Program.contactName:newContactName, Program.defaultLocation:newLocation}).where(Program.id==programId) - updatedProgram.execute() + program: Program = Program.get_by_id(programId) + Program.update({Program.programName:newProgramName, Program.contactEmail: newContactEmail, Program.contactName:newContactName, Program.defaultLocation:newLocation}).where(Program.id == programId).execute() if newProgramName != program.programName: createAdminLog(f"{program.programName} Program Name was changed to: {newProgramName}") if newContactEmail != program.contactEmail: @@ -55,18 +80,19 @@ def changeProgramInfo(newProgramName, newContactEmail, newContactName, newLocati return (f'Program email info updated') -def getAllowedPrograms(currentUser): +def getAllowedPrograms(currentUser: User) -> List[Program]: """Returns a list of all visible programs depending on who the current user is.""" if currentUser.isCeltsAdmin: - return Program.select().order_by(Program.programName) + return list(Program.select().order_by(Program.programName)) + elif currentUser.isCeltsStudentAdmin: + return list(Program.select().where(Program.programName != "Bonner Scholars").order_by(Program.programName)) else: - return Program.select().join(ProgramManager).where(ProgramManager.user==currentUser).order_by(Program.programName) + return list(Program.select().join(ProgramManager).where(ProgramManager.user==currentUser).order_by(Program.programName)) - -def getAllowedTemplates(currentUser): +def getAllowedTemplates(currentUser: User) -> List[EventTemplate]: """Returns a list of all visible templates depending on who the current user is. If they are not an admin it should always be none.""" - if currentUser.isCeltsAdmin: + if currentUser.isCeltsAdmin or currentUser.isCeltsStudentAdmin: return EventTemplate.select().where(EventTemplate.isVisible==True).order_by(EventTemplate.name) else: return [] \ No newline at end of file diff --git a/app/logic/utils.py b/app/logic/utils.py index 6a7e654a3..b0e8a9eed 100644 --- a/app/logic/utils.py +++ b/app/logic/utils.py @@ -15,7 +15,7 @@ def selectSurroundingTerms(currentTerm, prevTerms=2): To get only the current and future terms, pass prevTerms=0. """ startTerm = max(1, currentTerm.id - prevTerms) - surroundingTerms = (Term.select() + surroundingTerms = list(Term.select() .where(Term.id >= startTerm) .where((Term.year <= currentTerm.year + 2)) .order_by(Term.termOrder)) diff --git a/app/models/user.py b/app/models/user.py index 96faa0583..78f7e023f 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -16,6 +16,7 @@ class User(baseModel): isStaff = BooleanField(default = False) isCeltsAdmin = BooleanField(default =False) isCeltsStudentStaff = BooleanField(default = False) + isCeltsStudentAdmin = BooleanField(default = False) dietRestriction = TextField(null=True) minorInterest = BooleanField(default=False) @@ -28,7 +29,7 @@ def __init__(self,*args, **kwargs): @property def isAdmin(self): - return (self.isCeltsAdmin or self.isCeltsStudentStaff) + return (self.isCeltsAdmin or self.isCeltsStudentAdmin or self.isCeltsStudentStaff) @property def isBonnerScholar(self): diff --git a/app/static/js/userManagement.js b/app/static/js/userManagement.js index aeee1312d..f4aff5f3e 100644 --- a/app/static/js/userManagement.js +++ b/app/static/js/userManagement.js @@ -6,6 +6,9 @@ function callbackAdmin(selected){ function callbackStudentStaff(selected){ submitRequest("addCeltsStudentStaff", selected.username) } +function callbackStudentAdmin(selected){ + submitRequest("addCeltsStudentAdmin", selected.username) +} $(document).ready(function(){ // Admin Management $("#searchCeltsAdminInput").on("input", function(){ @@ -14,6 +17,10 @@ $(document).ready(function(){ $("#searchCeltsStudentStaffInput").on("input", function(){ searchUser("searchCeltsStudentStaffInput", callbackStudentStaff, false, null, "student") }); + + $("#searchCeltsStudentAdminInput").on("input", function(){ + searchUser("searchCeltsStudentAdminInput", callbackStudentAdmin, false, null, "student") + }); $("#addNewTerm").on("click",function(){ addNewTerm(); }); @@ -23,6 +30,9 @@ $(document).ready(function(){ $(".removeStudentStaff").on("click",function(){ submitRequest("removeCeltsStudentStaff", $(this).data("username")); }); + $(".removeStudentAdmin").on("click",function(){ + submitRequest("removeCeltsStudentAdmin", $(this).data("username")); + }); $('#searchCeltsAdminInput').keydown(function(e){ if (e.key === "Enter"){ submitRequest("addCeltsAdmin", $(this).val()) @@ -33,7 +43,11 @@ $(document).ready(function(){ submitRequest("addCeltsStudentStaff", $(this).val()) } }); - + $('#searchCeltsStudentAdminInput').keydown(function(e){ + if (e.key === "Enter"){ + submitRequest("addCeltsStudentAdmin", $(this).val()) + } +}); for (var i = 1; i <= $('#currentTermList .term-btn').length; i++){ $("#termFormID_" + i).on("click", function(){ $(".term-btn").removeClass("active"); diff --git a/app/templates/admin/userManagement.html b/app/templates/admin/userManagement.html index f196df1c5..4cdc1d198 100644 --- a/app/templates/admin/userManagement.html +++ b/app/templates/admin/userManagement.html @@ -17,64 +17,86 @@

Admin Management

-
-

- {% set focus = "open" if not visibleAccordion or visibleAccordion == "user" else "collapsed" %} - -

- {% set show = "show" if not visibleAccordion or visibleAccordion == "user" %} -
-
-
-
-
-
- {{createInputsButtons("searchCeltsAdminInput", "Add Celts Admin")}}
+ {% if g.current_user.isCeltsAdmin%} +
+

+ {% set focus = "open" if not visibleAccordion or visibleAccordion == "user" else "collapsed" %} + +

+ {% set show = "show" if not visibleAccordion or visibleAccordion == "user" %} +
+
+
+
+
+
+ {{createInputsButtons("searchCeltsAdminInput", "Add Celts Admin")}}
+
+ + + + + + + + + {% for admin in currentAdmins %} + + + + + {% endfor %} + +
Current Admin
{{admin.firstName}} {{admin.lastName}}
- - - - - - - - - {% for admin in currentAdmins %} - - - - - {% endfor %} - +
+
+ {{createInputsButtons("searchCeltsStudentStaffInput", "Add Celts Student Staff")}}
+
+
Current Admin
{{admin.firstName}} {{admin.lastName}}
+ + + + + + + {% for studentStaff in currentStudentStaff %} + + + + + {% endfor %} +
Current Student Staff
{{studentStaff.firstName}} {{studentStaff.lastName}}
-
-
-
- {{createInputsButtons("searchCeltsStudentStaffInput", "Add Celts Student Staff")}}
- - - - - - - - {% for studentStaff in currentStudentStaff %} +
+
+ {{createInputsButtons("searchCeltsStudentAdminInput", "Add Celts Student Admin")}}
+
+
Current Student Staff
+ - - - - {% endfor %} - -
{{studentStaff.firstName}} {{studentStaff.lastName}}
+ Current Student Admin + + + + {% for studentAdmin in currentStudentAdmin %} + + {{studentAdmin.firstName}} {{studentAdmin.lastName}} + + + {% endfor %} + + +
-
+ {% endif %}

{% set focus = "open" if visibleAccordion == "term" else "collapsed" %} diff --git a/app/templates/eventNav.html b/app/templates/eventNav.html index a9ae7318c..2492b595f 100644 --- a/app/templates/eventNav.html +++ b/app/templates/eventNav.html @@ -33,8 +33,7 @@ {% endblock %} {% block navbar %} - {% if g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerFor(event.program)) %} - + {% if g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentAdmin and not eventData["program"].isBonnerScholars) or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerFor(eventData['program'])) %}