Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0c03375
Add CCE Minor Note tag to user profile Notes section
munsakad Jun 19, 2026
e3ce770
Merge branch 'development' into dee_and_bright_CCE_Minor_Note_feature
MImran2002 Jun 23, 2026
2b6ab23
Merge branch 'development' into dee_and_bright_CCE_Minor_Note_feature
MImran2002 Jul 6, 2026
6bfc7fc
Added CCE Minor support to profile notes
brightfietsop-ux Aug 3, 2026
34078cb
Changed wording of Manage Proposals to My Proposals if the user is a …
ACBerea Jul 16, 2026
eed0397
Fixed edge case when switching profiles between students causing the …
ACBerea Jul 16, 2026
7b589dc
Fixed redunancy in checks user identity checks when changing Manage P…
ACBerea Jul 16, 2026
829e1f6
Separate zero-hour events into Education and Training section
BhushanSah Jul 16, 2026
b98d30c
Initial commit
BhushanSah Jul 16, 2026
f92d2cc
Changed the dropdown to individual buttons
BhushanSah Jul 16, 2026
09e51c5
Removed the id categoryDropdown
BhushanSah Jul 16, 2026
34e5421
changed the title of 'Edit Volunteer Information' -> 'Edit Personal...'
fritzj2 Jul 16, 2026
6781a43
Fix volunteer spreadsheet tests for term and senior results
BhushanSah Jul 17, 2026
b2c8354
Updated profile note tests for CCE Minor support hence fixing the tes…
brightfietsop-ux Aug 3, 2026
f9c1f31
Merge branch 'development' into dee_and_bright_CCE_Minor_Note_feature
brightfietsop-ux Aug 3, 2026
ebe595f
refactored the page
brightfietsop-ux Aug 4, 2026
228b943
added some try except cases and user check before a note is added
brightfietsop-ux Aug 4, 2026
4f2a9bd
fixed the broken test
brightfietsop-ux Aug 4, 2026
4b9c91a
reformatted the code
brightfietsop-ux Aug 4, 2026
89f5edd
fixed the format of the code
brightfietsop-ux Aug 4, 2026
36cd7d0
fixed the layout of the page
brightfietsop-ux Aug 4, 2026
c7099d0
Revert local database reset changes
brightfietsop-ux Aug 4, 2026
717d933
Merge branch 'development' into dee_and_bright_CCE_Minor_Note_feature
MImran2002 Aug 4, 2026
190c30e
Address profile note review feedback and restore flash messages
brightfietsop-ux Aug 4, 2026
0f42d62
pulled origin into my branch
brightfietsop-ux Aug 4, 2026
e903a81
resolved merge conflict
brightfietsop-ux Aug 4, 2026
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
45 changes: 35 additions & 10 deletions app/controllers/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from app.logic.landingPage import getManagerProgramDict, getActiveEventTab
from app.logic.minor import toggleMinorInterest, declareMinorInterest, getCommunityEngagementByTerm, getEngagementTotal
from app.logic.participants import unattendedRequiredEvents, trainedParticipants, getParticipationStatusForTrainings, checkUserRsvp, addPersonToEvent
from app.logic.users import addUserInterest, removeUserInterest, banUser, unbanUser, isEligibleForProgram, getUserBGCheckHistory, addProfileNote, deleteProfileNote, updateDietInfo
from app.logic.users import addUserInterest, removeUserInterest, banUser, unbanUser, isEligibleForProgram, getUserBGCheckHistory,addProfileNote, deleteProfileNote, updateDietInfo, updateProfileNote, getProfileNoteData

@main_bp.route('/logout', methods=['GET'])
def redirectToLogout():
Expand Down Expand Up @@ -378,21 +378,46 @@ def eventTravelForm(eventID):
userList = userList,
)

@main_bp.route('/profile/addNote', methods=['POST'])
@main_bp.route("/profile/addNote", methods=["POST"])
def addNote():
"""
This function adds a note to the user's profile.
"""
postData = request.form
try:
note = addProfileNote(postData["visibility"], postData["bonner"] == "yes", postData["noteTextbox"], postData["username"])
noteData = getProfileNoteData(request.form, includeUsername=True, )
addProfileNote(**noteData)
flash("Successfully added profile note", "success")
return redirect(url_for("main.viewUsersProfile", username=postData["username"]))
except Exception as e:
print("Error adding note", e)
except ValueError as error:
flash(str(error), "danger")
return str(error), 400
except User.DoesNotExist:
flash("User not found", "danger")
return "User not found", 404
except Exception as error:
print("Error adding profile note:", error)
flash("Failed to add profile note", "danger")
return "Failed to add profile note", 500
return "success"

@main_bp.route("/<username>/editNote", methods=["POST"])
def editProfileNote(username):
try:
noteData = getProfileNoteData( request.form,includeId=True, )
profileNote = ProfileNote.get_by_id( noteData["profileNoteID"] )
if profileNote.user.username != username:
abort(403)
if ( profileNote.note.createdBy != g.current_user and not g.current_user.isCeltsAdmin ):
abort(403)
updateProfileNote(**noteData)
flash("Successfully updated profile note", "success")
except ValueError as error:
flash(str(error), "danger")
return str(error), 400
except ProfileNote.DoesNotExist:
flash("Profile note not found", "danger")
return "Profile note not found", 404
except Exception as error:
print("Error updating profile note:", error)
flash("Failed to update profile note", "danger")
return "Failed to update profile note", 500
return "success"

@main_bp.route('/<username>/deleteNote', methods=['POST'])
def deleteNote(username):
Expand Down
52 changes: 40 additions & 12 deletions app/logic/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,48 @@ def getUserBGCheckHistory(username):
for row in allBackgroundChecks:
bgHistory[row.type_id].append(row)
return bgHistory

def addProfileNote(visibility, bonner, noteTextbox, username):
def getProfileNoteData(formData, includeUsername=False, includeId=False):
noteData = {
"visibility": int(formData.get("visibility", 1)),
"bonner": formData.get("bonner") == "yes",
"cceMinor": formData.get("cceMinor") == "yes",
"noteTextbox": formData.get("noteTextbox", "").strip(),
}
if not noteData["noteTextbox"]:
raise ValueError("Note cannot be empty")
if includeUsername:
noteData["username"] = formData.get("username")
if not noteData["username"]:
raise ValueError("Missing username")
if includeId:
noteData["profileNoteID"] = formData.get("id")
if not noteData["profileNoteID"]:
raise ValueError("Missing profile note ID")
return noteData

def addProfileNote(visibility, bonner, cceMinor, noteTextbox, username):
user = User.get(User.username == username)
visibility = int(visibility)
if bonner:
visibility = 1 # bonner notes are always admins and the student
visibility = 1

noteForDb = Note.create(createdBy = g.current_user,
createdOn = datetime.datetime.now(),
noteContent = noteTextbox,
noteType = "profile")
createProfileNote = ProfileNote.create(user = User.get(User.username == username),
note = noteForDb,
isBonnerNote = bonner,
viewTier = visibility)
return createProfileNote
noteForDb = Note.create( createdBy=g.current_user, createdOn=datetime.datetime.now(), noteContent=noteTextbox, noteType="profile" )
profileNote = ProfileNote.create( user=user, note=noteForDb, isBonnerNote=bonner, isCCEMinorNote=cceMinor, viewTier=visibility, )
return profileNote

def updateProfileNote( profileNoteID, visibility, bonner, cceMinor, noteTextbox):
profileNote = ProfileNote.get_by_id(profileNoteID)
visibility = int(visibility)
if bonner:
visibility = 1
note = profileNote.note
note.noteContent = noteTextbox
note.save()
profileNote.viewTier = visibility
profileNote.isBonnerNote = bonner
profileNote.isCCEMinorNote = cceMinor
profileNote.save()
return profileNote

def deleteProfileNote(noteId):
return ProfileNote.delete().where(ProfileNote.id == noteId).execute()
Expand Down
4 changes: 3 additions & 1 deletion app/models/profileNote.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from app.models.user import User
from app.models.note import Note


class ProfileNote(baseModel):
user = ForeignKeyField(User)
note = ForeignKeyField(Note, null=False)
isBonnerNote = BooleanField(default=False)
viewTier = IntegerField(default=3)
isCCEMinorNote = BooleanField(default=False)
viewTier = IntegerField(default=3)
Loading
Loading