-
Notifications
You must be signed in to change notification settings - Fork 24
Allow all facilitators + free-text story author (#1514) #1552
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,9 @@ def edit | |
|
|
||
| def create | ||
| @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 | ||
| authorize! @story | ||
|
|
||
| success = false | ||
|
|
@@ -131,7 +134,7 @@ def set_form_variables | |
| .references(:users) | ||
| .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)")) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropped |
||
| @windows_types = WindowsType.all | ||
| @workshops = authorized_scope(Workshop.all).includes(:windows_type).order(:title) | ||
| @categories_grouped = | ||
|
|
@@ -189,7 +192,7 @@ def story_params | |
| params.require(:story).permit( | ||
| :title, :rhino_body, :featured, :published, :publicly_visible, :publicly_featured, :youtube_url, :website_url, | ||
| :windows_type_id, :organization_id, :workshop_id, :external_workshop_title, | ||
| :created_by_id, :updated_by_id, :story_idea_id, :spotlighted_facilitator_id, :author_credit_preference, | ||
| :created_by_id, :updated_by_id, :story_idea_id, :spotlighted_facilitator_id, :author_credit_preference, :author_name, | ||
| category_ids: [], | ||
| sector_ids: [], | ||
| primary_asset_attributes: [ :id, :file, :_destroy ], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,8 @@ module AuthorCreditable | |
| }.freeze | ||
|
|
||
| def author_credit | ||
| free_text = try(:author_name) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return free_text if free_text.present? | ||
| person = created_by&.person | ||
|
Comment on lines
22
to
25
|
||
| case author_credit_preference | ||
| when "full_name" then person&.full_name || "Anonymous" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
| <!-- Meta Data (exact screenshot style) --> | ||
| <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 %> | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| <%= link_to @story.author_credit, person_path(@story.created_by) %> | ||
| <% else %> | ||
|
Comment on lines
+31
to
33
|
||
| <%= @story.author_credit %> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| class AddAuthorNameToStories < ActiveRecord::Migration[8.1] | ||
| def up | ||
| add_column :stories, :author_name, :string | ||
| end | ||
|
|
||
| def down | ||
| remove_column :stories, :author_name, if_exists: true | ||
| end | ||
| end |
There was a problem hiding this comment.
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_byto the current admin here to satisfy the required association whileauthor_namecarries the display credit.