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

Student admin #1063

Draft
wants to merge 44 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
064415d
initail commit
qasema Aug 31, 2023
378f998
update student admin
qasema Sep 1, 2023
7d19f29
update student admin
qasema Sep 1, 2023
bd4bf0b
update nav bar
qasema Sep 1, 2023
8600142
new updates
qasema Sep 1, 2023
148cbfb
update student admin role in test data
qasema Sep 1, 2023
86b43a3
Modified conditional logic for Student Admin in different areas.
ojmakinde Sep 6, 2023
ec5bf44
refactor Celts Admins
qasema Sep 6, 2023
d81bc7c
update event list
qasema Sep 6, 2023
1d505db
Merge branch 'development' into studentAdmin
AndersonStettner Sep 7, 2023
227866a
update permoissions
qasema Sep 7, 2023
0bd4a63
update user managment
qasema Sep 8, 2023
2f401f8
remove space
qasema Sep 8, 2023
7554fb3
remove debugging statement
qasema Sep 8, 2023
2d08374
Corrected conditional logic for edit event view
ojmakinde Sep 18, 2023
ffcf2c9
Corrected eventNav functionality for student admins
ojmakinde Sep 19, 2023
379e7ae
Merge branch 'development' into studentAdmin
AndersonStettner Sep 19, 2023
c9cbad0
Created test stubs
ojmakinde Sep 20, 2023
8ff3aa9
Added myself to test data and wrote a unit test for studentAdmin logic
ojmakinde Sep 21, 2023
293bd19
Merge branch 'studentAdmin' of github.com:BCStudentSoftwareDevTeam/ce…
ojmakinde Sep 21, 2023
60c7431
Corrected eligibilty view error
ojmakinde Sep 27, 2023
ad4fca6
Merge branch 'development' into studentAdmin
ojmakinde Oct 23, 2023
4b9c752
Merge branch 'development' into studentAdmin
AndersonStettner Oct 26, 2023
d1a2433
Corrected capitaliztion and string formatting on flash messages
ojmakinde Nov 8, 2023
740f6b8
Corrected capitaliztion and string formatting on flash messages
ojmakinde Nov 8, 2023
d5a2f74
fix conditions
qasema Nov 13, 2023
a340704
merge development
qasema Nov 13, 2023
bd4d1fd
bonnerscholars
qasema Nov 13, 2023
c54bf3b
fix expressions
qasema Nov 13, 2023
e50ca71
fix a bug
qasema Nov 13, 2023
7d90425
resolve merge conflict
qasema Nov 15, 2023
cc64881
Removed Finn Bledsoe as faculty
ojmakinde Dec 4, 2023
9bf62ff
remove condition
qasema Dec 4, 2023
5edb6cd
merge
qasema Dec 4, 2023
329d1d3
Merge branch 'development' into studentAdmin
AndersonStettner Jan 17, 2024
419d2a3
refactored the function to be more logical
azabeli Mar 1, 2024
1e44a8c
Merge branch 'studentAdmin' of github.com:BCStudentSoftwareDevTeam/ce…
azabeli Mar 1, 2024
807d724
resolved conflicts
bledsoef Mar 1, 2024
4600233
Merge branch 'studentAdmin' of github.com:BCStudentSoftwareDevTeam/ce…
bledsoef Mar 1, 2024
86efbc6
updated test data and removed unused routes
bledsoef Mar 11, 2024
1415951
did a little refactoring and added some typing
bledsoef Mar 11, 2024
44d1927
added some more typing and did a little more refactoring
bledsoef Mar 11, 2024
6381d44
changing tests and reformatting logic/controllers to make them more t…
bledsoef Mar 11, 2024
f560f80
rewrote many tests
bledsoef Mar 11, 2024
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
13 changes: 6 additions & 7 deletions app/controllers/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ 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:
if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentStaff or g.current_user.isCeltsStudentAdmin :
ojmakinde marked this conversation as resolved.
Show resolved Hide resolved
allprograms = getAllowedPrograms(g.current_user)
visibleTemplates = getAllowedTemplates(g.current_user)
return render_template("/events/template_selector.html",
Expand All @@ -59,7 +58,7 @@ def templateSelect():

@admin_bp.route('/eventTemplates/<templateid>/<programid>/create', methods=['GET','POST'])
def createEvent(templateid, programid):
if not (g.current_user.isAdmin or g.current_user.isProgramManagerFor(programid)):
if not (g.current_user.isAdmin or g.current_user.isCeltsStudentAdmin or g.current_user.isProgramManagerFor(programid)):
ojmakinde marked this conversation as resolved.
Show resolved Hide resolved
abort(403)

# Validate given URL
Expand Down Expand Up @@ -144,7 +143,7 @@ def rsvpLogDisplay(eventId):
eventData = model_to_dict(event, recurse=False)
eventData['program'] = event.program
isProgramManager = g.current_user.isProgramManagerFor(eventData['program'])
if g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and isProgramManager):
if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin or (g.current_user.isCeltsStudentStaff and isProgramManager):
ojmakinde marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the isCeltsStudentStaff check here, because all we care about is whether they are a program manager (and that will likely mean student staff is redundant)

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,
Expand All @@ -169,7 +168,7 @@ def eventDisplay(eventId):
print(f"Unknown event: {eventId}")
abort(404)

notPermitted = not (g.current_user.isCeltsAdmin or g.current_user.isProgramManagerForEvent(event))
notPermitted = not (g.current_user.isCeltsAdmin or g.current_user.isProgramManagerForEvent(event) or g.current_user.isCeltsStudentAdmin)
ojmakinde marked this conversation as resolved.
Show resolved Hide resolved
if 'edit' in request.url_rule.rule and notPermitted:
abort(403)

Expand Down Expand Up @@ -268,7 +267,7 @@ def eventDisplay(eventId):

@admin_bp.route('/event/<eventId>/cancel', methods=['POST'])
def cancelRoute(eventId):
if g.current_user.isAdmin:
if g.current_user.isAdmin or g.current_user.isCeltsStudentAdmin:
ojmakinde marked this conversation as resolved.
Show resolved Hide resolved
try:
cancelEvent(eventId)
return redirect(request.referrer)
Expand Down Expand Up @@ -330,7 +329,7 @@ def userProfile():

@admin_bp.route('/search_student', methods=['GET'])
def studentSearchPage():
if g.current_user.isAdmin:
if g.current_user.isAdmin or g.current_user.isCeltsStudentAdmin:
return render_template("/admin/searchStudentPage.html")
abort(403)

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/volunteers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def manageVolunteersPage(eventID):

isProgramManager = g.current_user.isProgramManagerForEvent(event)
bannedUsers = [row.user for row in getBannedUsers(event.program)]
if not (g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and isProgramManager)):
if not (g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin or (g.current_user.isCeltsStudentStaff and isProgramManager)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. the isCeltsStudentStaff check is redundant with isProgramManager

abort(403)

eventParticipantData = list(EventParticipant.select(EventParticipant, User).join(User).where(EventParticipant.event==event))
Expand Down Expand Up @@ -108,7 +108,7 @@ def volunteerDetailsPage(eventID):
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))):
if not (g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerForEvent(event))):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And again here

abort(403)

eventRsvpData = list(EventRsvp.select().where(EventRsvp.event==event))
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def viewUsersProfile(username):
else:
abort(403) # Error 403 if non admin/student-staff user trys to access via url

if (g.current_user == volunteer) or g.current_user.isAdmin:
if (g.current_user == volunteer) or g.current_user.isAdmin or g.current_user.isCeltsStudentAdmin:
upcomingEvents = getUpcomingEventsForUser(volunteer)
participatedEvents = getParticipatedEventsForUser(volunteer)
programs = Program.select()
Expand Down Expand Up @@ -429,7 +429,7 @@ def serviceTranscript(username):
user = User.get_or_none(User.username == username)
if user is None:
abort(404)
if user != g.current_user and not g.current_user.isAdmin:
if user != g.current_user and not g.current_user.isAdmin and not g.current_user.isCeltsStudentAdmin:
abort(403)

slCourses = getSlCourseTranscript(username)
Expand Down
2 changes: 1 addition & 1 deletion app/logic/userManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def changeProgramInfo(newProgramName, newContactEmail, newContactName, newLocati

def getAllowedPrograms(currentUser):
"""Returns a list of all visible programs depending on who the current user is."""
if currentUser.isCeltsAdmin:
if currentUser.isCeltsAdmin or g.current_user.isCeltsStudentAdmin:
return Program.select().order_by(Program.programName)
else:
return Program.select().join(ProgramManager).where(ProgramManager.user==currentUser).order_by(Program.programName)
Expand Down
1 change: 1 addition & 0 deletions app/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class User(baseModel):
isStaff = BooleanField(default = False)
isCeltsAdmin = BooleanField(default =False)
isCeltsStudentStaff = BooleanField(default = False)
isCeltsStudentAdmin = BooleanField(default = False)
dietRestriction = TextField(null=True)

# override BaseModel's __init__ so that we can set up an instance attribute for cache
Expand Down
4 changes: 2 additions & 2 deletions app/templates/eventNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% block app_content %}
{% block content_pageHeading %}
<div class="text-center">
{% if g.current_user.isAdmin %}
{% if g.current_user.isAdmin or g.current_user.isCeltsStudentAdmin %}
{{ eventheader(page_title, eventData, 'large', isNewEvent) }}
{% endif %}
{% set alertClass = "alert-danger" if eventPast else "alert-warning"%}
Expand All @@ -33,7 +33,7 @@
{% endblock %}

{% block navbar %}
{% if g.current_user.isCeltsAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerFor(eventData['program'])) %}
{% if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin or (g.current_user.isCeltsStudentStaff and g.current_user.isProgramManagerFor(eventData['program'])) %}

<div class="btn-group">
<ul class="nav nav-tabs nav-fill mx-3 mb-3" id="pills-tab" role="tablist">
Expand Down
6 changes: 3 additions & 3 deletions app/templates/eventView.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% set fullWidthTitle = not (g.current_user.isAdmin or image) %}
<div class="{{ 'col-md-12' if fullWidthTitle else 'col-md-6'}}">

{%if not g.current_user.isAdmin %}
{%if not g.current_user.isAdmin or not g.current_user.isCeltsStudentAdmin %}
{{ eventheader(eventData.name, eventData, 'small', isNewEvent) }}
{% endif %}

Expand Down Expand Up @@ -132,7 +132,7 @@ <h3>Contact Information:</h3>
<h3>Program Trainings:</h3>
{% for training, events in programTrainings.items() %}
{% for eventObj, attended in events %}
{% if g.current_user.isCeltsAdmin %}
{% if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin %}
<p>{{eventObj.name}}</p>
{% elif attended %}
<p><b>{{eventObj.name}}</b>: Attended</p>
Expand Down Expand Up @@ -161,7 +161,7 @@ <h3>Program Trainings:</h3>
{% endif %}
</div>
<div class="rsvp-btn text-center">
{% if g.current_user.isCeltsAdmin or isProgramManager %}
{% if g.current_user.isCeltsAdmin or g.current_user.isCeltsStudentAdmin or isProgramManager %}
<div class="d-flex align-items-center">
<i class="bi bi-eye-fill me-2"></i>
<span class="me-2">Unique Viewers:</span>
Expand Down
7 changes: 4 additions & 3 deletions app/templates/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
</a>
</li>

{% if g.current_user.isFaculty and not g.current_user.isAdmin%}
{% if g.current_user.isFaculty and not g.current_user.isAdmin and not g.current_user.isCeltsStudentAdmin %}
<li>
<a href="/serviceLearning/courseManagement" class="nav-link text-white {{'active' if request.path =='/serviceLearning/courseManagement'}}" {{"aria-current='page'" if request.path =='/serviceLearning/courseManagement'}}>
Course Proposals
</a>
</li>
{% endif %}

{% if g.current_user.isAdmin %}
{% if g.current_user.isAdmin or g.current_user.isCeltsStudentAdmin %}
<li>
<a href="/eventTemplates" class="nav-link text-white {{'active' if 'eventTemplates' in request.path}}" {{"aria-current='page'" if 'eventTemplates' in request.path}}>
Create Event
Expand All @@ -38,7 +38,7 @@
</a>
</li>
<li>
{% if not g.current_user.isCeltsStudentStaff %}
{% if not g.current_user.isCeltsStudentStaff and not g.current_user.isCeltsStudentAdmin %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to if g.current_user.isCeltsAdmin

<a href="/serviceLearning/courseManagement" class="nav-link text-white {{'active' if request.path =='/serviceLearning/courseManagement'}}" {{"aria-current='page'" if request.path =='/serviceLearning/courseManagement'}}>
Course Proposals
</a>
Expand Down Expand Up @@ -82,6 +82,7 @@ <h6>Current User: {{g.current_user.username}}</h6>
<select name="newuser" class="form-select" style="margin-bottom: 10px" onchange="this.form.submit()">>
<option {{"selected" if g.current_user.username == config.default_user }} value="{{config.default_user}}">Default User: {{config.default_user}}</option>
<option {{"selected" if g.current_user.username == "ramsayb2"}} value="ramsayb2">Admin: ramsayb2</option>
<option {{"selected" if g.current_user.username == "bledsoef"}} value="bledsoef">Student Admin: bledsoef</option>
<option {{"selected" if g.current_user.username == "neillz"}} value="neillz">Student Staff: neillz</option>
<option {{"selected" if g.current_user.username == "ayisie"}} value="ayisie">Student: ayisie</option>
<option {{"selected" if g.current_user.username == "heggens"}} value="heggens">Faculty: heggens</option>
Expand Down
1 change: 1 addition & 0 deletions database/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
"isCeltsAdmin": False,
"isFaculty": True,
"isCeltsStudentStaff": False,
"isCeltsStudentAdmin": True,
"isStaff": True,
},
]
Expand Down
Loading