HOLD: Restrict ended events to registered users and grey out cards#1330
Open
HOLD: Restrict ended events to registered users and grey out cards#1330
Conversation
Ended events were visible to all users regardless of registration status. Now only admins and actively registered users can see them in the index and via direct URL. Ended event cards render with reduced opacity and muted styling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Hardcode active status values in policy join to avoid brakeman string interpolation warning - Register user for ended event in system spec so show? allows access - Update timezone test dates from 2025 to 2031 (now past, causing ended event policy to block access) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3f77f25 to
d8aeef8
Compare
- Card: show "Event ended" label alongside "View registration" button for registered users on ended events - Registration section: restructure conditionals so ended events show "Event ended" above "View Registration" without also showing "Registration closed" - Hide calendar links on ended events since the dates have passed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
System specs: - Registered user sees both "Event ended" and "View Registration" - Calendar links hidden on ended events - Unregistered user blocked from ended event show page - Admin can view ended events Request specs: - Admin can view ended event (200) - Registered user can view ended event (200) - Unregistered user redirected from ended event - Unauthenticated user redirected to sign in Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ActionPolicy::Unauthorized rescues redirect to root_path, not sign_in, since the event is publicly visible and guests can reach the controller. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the goal of this PR and why is this important?
How did you approach the change?
Policy (
EventPolicy):show?now checksended?— only admins and actively registered users can view ended events via direct URLrelation_scopefor authenticated users uses a manual LEFT OUTER JOIN filtered to active registration statuses, withend_date >= nowfor upcoming events ORpeople.id = person_idfor registered eventsrelation_scopefor unauthenticated users addsend_date >= nowfilter to exclude all ended eventsCard styling (
_card.html.erb):class_nameswith conditional classes: ended events getbg-gray-100 border-gray-300 opacity-60, active events keepbg-white border-gray-200 hover:shadow-mdTests:
:endedfactory traitshow?tests for ended events (admin, registered, unregistered, unauthenticated)relation_scopetests to verifyend_dateand active status filteringUI Testing Checklist
Anything else to add?
_registration_section.html.erbalready showed "Event ended" text — no changes needed there🤖 Generated with Claude Code