Skip to content
Merged
6 changes: 6 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@
"Bash(bundle exec rubocop:*)",
"Bash(git -C /Users/maebeale/programming/awbw diff --name-only main...HEAD)",
"Bash(git log:*)",

"Bash(git fetch:*)",
"Bash(git rebase:*)",
"Bash(grep:*)"

"Bash(bin/rails generate:*)",
"Bash(bin/rails db:schema:dump:*)",
"Bash(RAILS_ENV=test bin/rails:*)"

]
}
}
2 changes: 1 addition & 1 deletion app/controllers/story_ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def set_form_variables
@user = User.find(params[:user_id]) if params[:user_id].present?
@organizations = (@user || current_user)&.organizations&.order(:name) || Organization.none
@windows_types = WindowsType.all
@workshops = Workshop.order(:title)
@workshops = Workshop.includes(:windows_type).order(:title)

@users = User.has_access.includes(:person)
@users = @users.or(User.where(id: @story_idea.created_by_id)) if @story_idea&.created_by_id
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/workshop_ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ def destroy
# Optional hooks for setting variables for forms or index
def set_form_variables
@age_ranges = Category.includes(:category_type).where("category_types.name = 'AgeRange'").pluck(:name)
@potential_series_workshops = Workshop.published.order(:title)
@potential_series_workshops = Workshop.published.includes(:windows_type).order(:title)
@sectors = Sector.published
@windows_types = WindowsType.all
@authors = User.has_access.includes(:person).sort_by { |u| u.name.downcase }
@categories_grouped =
Category
.includes(:category_type)
Expand Down
1 change: 1 addition & 0 deletions app/controllers/workshop_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def set_index_variables # needs to not be private
.order("people.first_name, people.last_name")
@organizations = authorized_scope(Organization.all)
@workshops = Workshop.where(id: @workshop_logs_unpaginated.select(:workshop_id).distinct)
.includes(:windows_type)
.order(:title)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/workshop_variation_ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def set_form_variables
@workshop_variation_idea.build_primary_asset if @workshop_variation_idea.primary_asset.blank?
@workshop_variation_idea.gallery_assets.build

@workshops = Workshop.published.order(:title)
@workshops = Workshop.published.includes(:windows_type).order(:title)
@organizations = authorized_scope(Organization.all).order(:name)
@windows_types = WindowsType.order(:name)
@users = User.has_access.or(User.where(id: @workshop_variation_idea.created_by_id))
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/workshops_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def set_show

def set_form_variables
@age_ranges = Category.includes(:category_type).where("category_types.name = 'AgeRange'").pluck(:name)
@potential_series_workshops = Workshop.published.where.not(id: @workshop.id).order(:title)
@potential_series_workshops = Workshop.published.includes(:windows_type).where.not(id: @workshop.id).order(:title)
@windows_types = WindowsType.all
@workshop_ideas = WorkshopIdea.order(created_at: :desc)
.map { |wi|
Expand Down
3 changes: 1 addition & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ def organization_workshop_logs(date, windows_type, organization_id)
end

def name
return email if !first_name || first_name.empty?
"#{first_name} #{last_name}"
person ? person.full_name : email
end

def primary_asset # method needed for idea_submitted_fyi mailer
Expand Down
2 changes: 1 addition & 1 deletion app/views/workshop_ideas/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<%= f.input :created_by_id,
as: :select,
label: "Author",
collection: User.order(:last_name, :first_name),
collection: @authors,
selected: f.object.created_by_id || current_user.id,
input_html: { class: "block w-full rounded-md border-gray-300 shadow-sm
focus:ring-blue-500 focus:border-blue-500 sm:text-sm" } %>
Expand Down
86 changes: 46 additions & 40 deletions app/views/workshop_logs/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,58 @@
</div>
<% end %>
<!-- Workshop Selection -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
<%= f.input :workshop_id,
as: :select,
collection: @workshops,
label_method: :type_name,
value_method: :id,
label: "Workshop",
prompt: "Select a Workshop",
required: true,
selected: params[:workshop_id].presence || f.object.workshop_id,
input_html: { value: params[:workshop_id].presence || f.object.workshop_id,
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" },
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
<%= f.input :external_workshop_title,
as: :text,
label: "External title (if no workshop above)",
input_html: {
rows: 1,
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500"
},
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
<% if current_user.person&.organization_people&.count != 1 %>
<%= f.input :organization_id,
<div class="flex flex-col md:flex-row md:space-x-4 mb-6">
<div class="flex-1 mb-4 md:mb-0">
<%= f.input :workshop_id,
as: :select,
collection: @organizations,
collection: @workshops,
label_method: :type_name,
value_method: :id,
label: "Organization",
label: "Workshop",
prompt: "Select a Workshop",
required: true,
hint: "Please contact AWBW if your agency is not listed.",
prompt: (@organizations.count > 1 ? "Please select the relevant organization" : nil),
selected: (params[:organization_id].presence || (f.object.organization_id || (@organizations.count == 1 ? @organizations.first.id : nil))),
input_html: { value: params[:organization_id].presence || f.object.organization_id || @organization_id,
selected: params[:workshop_id].presence || f.object.workshop_id,
input_html: { value: params[:workshop_id].presence || f.object.workshop_id,
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" },
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
<% else current_user.person&.organization_people&.count == 1 %>
<%= f.hidden_field :organization_id,
value: f.object.organization_id || current_user.person.primary_organization&.id %>
<% end %>
<%= f.input :date,
label: "Workshop Date",
as: :string,
required: true,
input_html: { type: 'date', value: f.object.date&.strftime('%Y-%m-%d'),
class: "block w-fullrounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" },
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
<%= f.input :external_workshop_title,
as: :text,
label: "External title (if no workshop above)",
input_html: {
rows: 1,
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500"
},
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
</div>
<div class="flex-1 mb-4 md:mb-0">
<% if current_user.person&.organization_people&.count != 1 %>
<%= f.input :organization_id,
as: :select,
collection: @organizations,
label_method: :type_name,
value_method: :id,
label: "Organization",
required: true,
hint: "Please contact AWBW if your agency is not listed.",
prompt: (@organizations.count > 1 ? "Please select the relevant organization" : nil),
selected: (params[:organization_id].presence || (f.object.organization_id || (@organizations.count == 1 ? @organizations.first.id : nil))),
input_html: { value: params[:organization_id].presence || f.object.organization_id || @organization_id,
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" },
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
<% else current_user.person&.organization_people&.count == 1 %>
<%= f.hidden_field :organization_id,
value: f.object.organization_id || current_user.person.primary_organization&.id %>
<% end %>
</div>
<div class="flex-1 mb-4 md:mb-0">
<%= f.input :date,
label: "Workshop Date",
as: :string,
required: true,
input_html: { type: 'date', value: f.object.date&.strftime('%Y-%m-%d'),
class: "block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" },
label_html: { class: "block text-sm font-medium text-gray-700 mb-1" } %>
</div>
</div>
<!-- Participants Section -->
<hr class="my-6 border-gray-200">
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/notification_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
it "renders the headers" do
expect(mail.subject).to include("AWBW portal:")
expect(mail.subject).to include("password reset")
expect(mail.subject).to include(notification.noticeable.name)
expect(mail.subject).to include(notification.noticeable.full_name)
expect(mail.to).to eq([ ENV.fetch("REPLY_TO_EMAIL", "programs@awbw.org") ])
expect(mail.from).to eq([ ENV.fetch("REPLY_TO_EMAIL", "programs@awbw.org") ])
expect(mail.reply_to).to eq([ ENV.fetch("REPLY_TO_EMAIL", "programs@awbw.org") ])
Expand Down
14 changes: 5 additions & 9 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,14 @@
end

describe "#name" do
it "returns first and last name when present" do
user = build(:user, first_name: "Bob", last_name: "Smith")
it "returns person full_name when person is present" do
person = build(:person, first_name: "Bob", last_name: "Smith")
user = build(:user, person: person)
expect(user.name).to eq("Bob Smith")
end

it "returns email when first_name is nil" do
user = build(:user, first_name: nil)
expect(user.name).to eq(user.email)
end

it "returns email when first_name is empty" do
user = build(:user, first_name: "")
it "returns email when no person" do
user = build(:user, person: nil)
expect(user.name).to eq(user.email)
end
end
Expand Down