Skip to content
Open
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
3 changes: 3 additions & 0 deletions app/controllers/minor/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def viewCceMinor(username):
"""
Load minor management page with community engagements and summer experience
"""
if not (g.current_user.isAdmin or g.current_user.username == username or g.current_user.isCeltsStudentStaff):
return abort(403)

sustainedEngagementByTerm = getCommunityEngagementByTerm(username)

activeTab = request.args.get("tab", "sustainedCommunityEngagements")
Expand Down
35 changes: 29 additions & 6 deletions app/logic/celtsLabor.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,37 @@ def refreshCeltsLaborRecords(laborDict):
def getCeltsLaborHistory(volunteer):

laborHistoryList = list(CeltsLabor.select(CeltsLabor.positionTitle,
CeltsLabor.id,
Term.description,
Term.academicYear,
Term.isSummer)
.join(Term, on=(CeltsLabor.term == Term.id))
.where(CeltsLabor.user == volunteer))

.where(CeltsLabor.user == volunteer)
.order_by(Term.termOrder.asc()))
termsByAcademicYear = {}
for position in laborHistoryList:
if position.term.isSummer:
continue
academicYear = position.term.academicYear
description = position.term.description
if academicYear not in termsByAcademicYear:
termsByAcademicYear[academicYear] = {"Fall": False,"Spring": False}
if "Fall" in description:
termsByAcademicYear[academicYear]["Fall"] = True
elif "Spring" in description:
termsByAcademicYear[academicYear]["Spring"] = True
laborHistoryDict= {}
for position in laborHistoryList:
laborHistoryDict[position.positionTitle] = position.term.description if position.term.isSummer else position.term.academicYear

return laborHistoryDict
for position in laborHistoryList:
description = position.term.description
academicYear = position.term.academicYear
if position.term.isSummer:
positionTerm = description
else:
hasFall = termsByAcademicYear[academicYear]["Fall"]
hasSpring = termsByAcademicYear[academicYear]["Spring"]
if hasFall and hasSpring:
positionTerm = description
else:
positionTerm = f"AY {academicYear}"
laborHistoryDict[position.id] = (position.positionTitle,positionTerm)
return laborHistoryDict
15 changes: 7 additions & 8 deletions app/logic/searchUsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ def searchUsers(query, category=None):
'''
# add wildcards to each piece of the query
splitSearch = query.strip().split()
firstName = splitSearch[0] + "%"
lastName = " ".join(splitSearch[1:]) +"%"

if len(splitSearch) == 1: # search for query in first OR last name
searchWhere = (User.firstName ** firstName | User.lastName ** firstName | User.username ** splitSearch)
else: # search for first AND last name
searchWhere = (User.firstName ** firstName & User.lastName ** lastName)

fullSearch = " ".join(splitSearch) + "%"
searchWhere = (User.firstName ** fullSearch | User.lastName ** fullSearch | User.username ** fullSearch)
for splitIndex in range(1, len(splitSearch)):
firstName = " ".join(splitSearch[:splitIndex]) + "%"
lastName = " ".join(splitSearch[splitIndex:]) + "%"
searchWhere |= (User.firstName ** firstName & User.lastName ** lastName)

if category == "instructor":
userWhere = (User.isFaculty | User.isStaff)
elif category == "admin":
Expand Down
4 changes: 2 additions & 2 deletions app/templates/main/userProfile.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ <h3 class="accordion-header" id="headingFour">
{% if participatedInLabor %}
<div class="col-md-6">
<h5>CELTS Labor History:</h5>
{% for program, term in participatedInLabor.items() %}
<p>{{term}}: {{program}}</p>
{% for positionTitle, term in participatedInLabor.values() %}
<p>{{term}}: {{positionTitle}}</p>
{% endfor %}
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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 == "neillz"}} value="neillz">Student Staff: neillz</option>
<option {{"selected" if g.current_user.username == "velazquezdiaza"}} value="velazquezdiaza">Student Staff: velazquezdiaza</option>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this work with our test data?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pick a different user, as this is exposing this user's labor and service records to our team.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will definitely work on it and the config for api as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

While we are here, we will be changing the language from "Student Staff" to "Program Manager" for this role. Later, we will add another role of "Operations Team" which has slightly elevated privileges from a PM.

<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>
</select>
Expand Down
19 changes: 15 additions & 4 deletions tests/code/test_celtsLabor.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,24 @@ def test_getCeltsLaborHistory():
isAcademicYear = True)


testDataAyisieHistory = {"Bonner Manager": "Summer 2021"}
testDataAyisieHistory = [('Bonner Manager', 'Summer 2021')]
getAyisieHistory = getCeltsLaborHistory(ayisie)

testDataMupotsalHistory = {"Habitat For Humanity Cord.": "2020-2021"}
testDataMupotsalHistory = [('Habitat For Humanity Cord.', 'AY 2020-2021')]
getMupotsalHistory = getCeltsLaborHistory(mupotsal)

assert getAyisieHistory == testDataAyisieHistory
assert getMupotsalHistory == testDataMupotsalHistory
assert list(getAyisieHistory.values()) == testDataAyisieHistory
assert list(getMupotsalHistory.values()) == testDataMupotsalHistory

CeltsLabor.create(user = mupotsal,
positionTitle = "Bonner Manager",
term = Term.get_by_id(1),
isAcademicYear = True)

#this is to test if there are two different celts labor in a academic year it no longers show AY 2020-2021 instead shows Fall and Spring in ascending order
testDataMupotsalHistoryFallSpring = [('Bonner Manager', 'Fall 2020'), ('Habitat For Humanity Cord.', 'Spring 2021')]
getMupotsalHistory = getCeltsLaborHistory(mupotsal)

assert list(getMupotsalHistory.values()) == testDataMupotsalHistoryFallSpring

transaction.rollback()
Loading