Skip to content

Allow all facilitators + free-text story author (#1514)#1552

Open
maebeale wants to merge 1 commit into
mainfrom
maebeale/story-author-free-text
Open

Allow all facilitators + free-text story author (#1514)#1552
maebeale wants to merge 1 commit into
mainfrom
maebeale/story-author-free-text

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Jun 5, 2026

Closes #1514

What is the goal of this PR and why is this important?

  • The new/edit story author dropdown only listed active, confirmed users (User.has_access), so facilitators who were inactive, never entered in the CMS, or only known by a first name could not be credited as the story author.
  • This mirrors the issue already fixed for the spotlighted facilitator dropdown, which lists all people.

How did you approach the change?

  • All facilitators in the dropdown: dropped the has_access filter from @users in StoriesController#set_form_variables, so the author dropdown lists all users — matching how the spotlighted-facilitator dropdown lists all Person records.
  • Free-text fallback: added a nullable author_name column (migration) plus an "Or type an author name" text input on the form, for facilitators not in the CMS or where only a first name is known.
  • Credit display: AuthorCreditable#author_credit now returns author_name when present, overriding the created_by person and the credit preference. The concern uses try(:author_name), so StoryIdea (no such column) is unaffected.
  • Required association: when a free-text author is entered without selecting a user, create defaults created_by to the current admin so the required created_by_id is satisfied.
  • Show page: the author profile link is suppressed when a free-text name is used, so it doesn't link to the admin creator's profile.

UI Testing Checklist

  • New/edit story form shows inactive facilitators in the author dropdown
  • Typing a free-text author name and submitting (without selecting a dropdown author) saves the story and shows that name under "Story by"
  • Selecting a dropdown author with a searchable profile still links to that person on the show page

Anything else to add?

  • Tests: model specs for the free-text author_credit override; request specs for free-text create (defaulting created_by) and inactive facilitators appearing in the dropdown. Full stories model + request specs pass.
  • db/schema.rb change is limited to the new column + version bump (unrelated local dev-DB drift was excluded).

🤖 Generated with Claude Code

The new/edit story form restricted the author dropdown to active,
confirmed users, so facilitators who were inactive, never entered in
the CMS, or only known by first name could not be credited. This
mirrors the earlier fix to the spotlighted-facilitator dropdown.

- Author dropdown now lists all users (drops the has_access filter),
  matching how the spotlighted-facilitator dropdown lists all people.
- Add an optional free-text "author name" that overrides the dropdown
  and credit preference, for facilitators not in the CMS.
- When a free-text author is given without selecting a user, default
  created_by to the current admin so the required association is set.
- Suppress the author profile link on the show page when a free-text
  name is used so it doesn't link to the admin creator.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 5, 2026 00:44
@story = Story.new(story_params.except(:category_ids, :sector_ids))
# A free-text author name covers facilitators who aren't in the CMS, so an
# author User may not be selected. Fall back to the current admin as creator.
@story.created_by_id ||= current_user.id
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Free-text authors may not be in the CMS, so no author User is selected. We default created_by to the current admin here to satisfy the required association while author_name carries the display credit.

}.freeze

def author_credit
free_text = try(:author_name)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

try(:author_name) so the shared concern keeps working for StoryIdea, which has no author_name column. Free text intentionally overrides the credit preference.

<div class="text-sm text-gray-600 space-y-0.5">
<p><strong>Story by:</strong>
<% if @story.created_by.person&.profile_is_searchable %>
<% if @story.author_name.blank? && @story.created_by.person&.profile_is_searchable %>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Suppress the profile link for free-text authors — otherwise it would link to the admin creator rather than the credited facilitator.

.order(:created_at)
@people = Person.order(Arel.sql("LOWER(first_name), LOWER(last_name)"))
@users = User.has_access.includes(:person).left_joins(:person).order(Arel.sql("people.first_name IS NULL, LOWER(people.first_name), LOWER(people.last_name), LOWER(users.email)"))
@users = User.includes(:person).left_joins(:person).order(Arel.sql("people.first_name IS NULL, LOWER(people.first_name), LOWER(people.last_name), LOWER(users.email)"))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Dropped has_access so inactive/unconfirmed facilitators are selectable, mirroring how the spotlighted-facilitator dropdown lists all people.

@maebeale maebeale marked this pull request as ready for review June 5, 2026 00:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands story author attribution to support (1) selecting any facilitator/user (including inactive/unconfirmed) and (2) entering a free-text author name when the facilitator isn’t in the CMS, while ensuring the show page displays the correct credit and avoids linking to the wrong profile.

Changes:

  • Adds stories.author_name (nullable) and a corresponding free-text input on the story form.
  • Removes the User.has_access filter so the story author dropdown includes inactive facilitators.
  • Updates author credit display logic and creation defaults (created_by_id) to support free-text author attribution.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
spec/requests/stories_spec.rb Adds request coverage for free-text author creation and inactive facilitators appearing in the author dropdown.
spec/models/story_spec.rb Adds model coverage ensuring author_name overrides author credit behavior when present.
db/schema.rb Captures schema version bump and new stories.author_name column.
db/migrate/20260604120000_add_author_name_to_stories.rb Adds reversible migration for stories.author_name.
app/views/stories/show.html.erb Suppresses profile link when free-text author name is used.
app/views/stories/_form.html.erb Adds free-text author input and keeps author dropdown for created_by_id.
app/models/concerns/author_creditable.rb Updates author_credit to prefer free-text author name when present.
app/controllers/stories_controller.rb Defaults created_by_id on create when no dropdown author is selected; permits author_name; broadens dropdown user scope.

Comment on lines 22 to 25
def author_credit
free_text = try(:author_name)
return free_text if free_text.present?
person = created_by&.person
Comment on lines +31 to 33
<% if @story.author_name.blank? && @story.created_by.person&.profile_is_searchable %>
<%= link_to @story.author_credit, person_path(@story.created_by) %>
<% else %>
@jmilljr24
Copy link
Copy Markdown
Collaborator

I'm still having a hard time with author being a User. I know there is more to it but adding a column for free text user feels off. If author was a Person we would just need to create the person with no user account. A Person is who authored the story. A User would be more in line with if they were logged in and we wanted to know who "created" the record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New story: story author dropdown should include all facilitators + free-text fallback

3 participants