From b54ca58d1ea2997d2d5c8538976023b559642c2a Mon Sep 17 00:00:00 2001 From: moveson Date: Sun, 22 Dec 2024 01:37:33 -0700 Subject: [PATCH] Add locals declarations in several views and partial calls --- app/controllers/subscriptions_controller.rb | 4 +++- app/views/event_groups/finish_line.html.erb | 2 +- app/views/event_groups/follow.html.erb | 2 +- app/views/event_groups/raw_times.html.erb | 2 +- app/views/event_groups/roster.html.erb | 2 +- app/views/event_groups/split_raw_times.html.erb | 2 +- app/views/event_groups/stats.html.erb | 2 +- app/views/event_groups/traffic.html.erb | 2 +- app/views/event_groups/webhooks.html.erb | 6 +++--- app/views/events/_time_and_course_info.html.erb | 8 +++++--- app/views/events/_view_buttons.html.erb | 2 ++ app/views/events/finish_history.html.erb | 2 +- app/views/events/podium.html.erb | 2 +- app/views/events/spread.html.erb | 2 +- app/views/events/summary.html.erb | 2 +- app/views/subscriptions/_subscriptions_count.html.erb | 4 +++- app/views/subscriptions/new.html.erb | 2 +- 17 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/controllers/subscriptions_controller.rb b/app/controllers/subscriptions_controller.rb index bd325c456..7c96dceb3 100644 --- a/app/controllers/subscriptions_controller.rb +++ b/app/controllers/subscriptions_controller.rb @@ -12,6 +12,8 @@ class SubscriptionsController < ApplicationController def new @subscription = @subscribable.subscriptions.new(user: current_user) authorize @subscription + + render :new, locals: { subscription: @subscription } end # POST /subscribable/:subscribable_id/subscriptions @@ -35,7 +37,7 @@ def create render :create, locals: { subscription: @subscription, subscribable: @subscribable, protocol: protocol } else if @subscription.subscribable.is_a?(Event) - render :new, status: :unprocessable_entity + render :new, locals: { subscription: @subscription }, status: :unprocessable_entity else flash.now[:danger] = @subscription.errors.full_messages.to_sentence render turbo_stream: turbo_stream.replace("flash", partial: "layouts/flash") diff --git a/app/views/event_groups/finish_line.html.erb b/app/views/event_groups/finish_line.html.erb index 5e0a1b04e..6888df4e9 100644 --- a/app/views/event_groups/finish_line.html.erb +++ b/app/views/event_groups/finish_line.html.erb @@ -18,7 +18,7 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/follow.html.erb b/app/views/event_groups/follow.html.erb index 51294b3ed..da4fefa8c 100644 --- a/app/views/event_groups/follow.html.erb +++ b/app/views/event_groups/follow.html.erb @@ -15,7 +15,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/raw_times.html.erb b/app/views/event_groups/raw_times.html.erb index 7977bc63e..0907a2b49 100644 --- a/app/views/event_groups/raw_times.html.erb +++ b/app/views/event_groups/raw_times.html.erb @@ -16,7 +16,7 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/roster.html.erb b/app/views/event_groups/roster.html.erb index 3dfb814fe..a80a6d8a3 100644 --- a/app/views/event_groups/roster.html.erb +++ b/app/views/event_groups/roster.html.erb @@ -20,7 +20,7 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/split_raw_times.html.erb b/app/views/event_groups/split_raw_times.html.erb index 610e25fde..819c122ae 100644 --- a/app/views/event_groups/split_raw_times.html.erb +++ b/app/views/event_groups/split_raw_times.html.erb @@ -16,7 +16,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/stats.html.erb b/app/views/event_groups/stats.html.erb index 561da0c72..630d74567 100644 --- a/app/views/event_groups/stats.html.erb +++ b/app/views/event_groups/stats.html.erb @@ -17,7 +17,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/traffic.html.erb b/app/views/event_groups/traffic.html.erb index b8f172694..4835c7be4 100644 --- a/app/views/event_groups/traffic.html.erb +++ b/app/views/event_groups/traffic.html.erb @@ -16,7 +16,7 @@ - <%= render 'events/time_and_course_info' %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/event_groups/webhooks.html.erb b/app/views/event_groups/webhooks.html.erb index 11313cc03..c01ed42b8 100644 --- a/app/views/event_groups/webhooks.html.erb +++ b/app/views/event_groups/webhooks.html.erb @@ -15,11 +15,11 @@ - <%= render "events/time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> - <%= render "events/view_buttons", view_object: @presenter %> + <%= render partial: "events/view_buttons", locals: { view_object: @presenter } %> @@ -50,7 +50,7 @@

<%= event.name %> - <%= render "subscriptions/subscriptions_count", subscribable: event, current_user: current_user %> + <%= render partial: "subscriptions/subscriptions_count", locals: { subscribable: event, current_user: current_user } %>

diff --git a/app/views/events/_time_and_course_info.html.erb b/app/views/events/_time_and_course_info.html.erb index 18acb5515..c064e5301 100644 --- a/app/views/events/_time_and_course_info.html.erb +++ b/app/views/events/_time_and_course_info.html.erb @@ -1,7 +1,9 @@ +<%# locals: (presenter:) %> +
-

<%= l(@presenter.scheduled_start_time_local, format: :full_day_time_and_zone) %> - <% if @presenter.respond_to?(:course) %> - on <%= link_to @presenter.course_name, organization_course_path(@presenter.organization, @presenter.course) %> +

<%= l(presenter.scheduled_start_time_local, format: :full_day_time_and_zone) %> + <% if presenter.respond_to?(:course) %> + on <%= link_to presenter.course_name, organization_course_path(presenter.organization, presenter.course) %> <% end %>

diff --git a/app/views/events/_view_buttons.html.erb b/app/views/events/_view_buttons.html.erb index 7cfbc958a..25164f3d2 100644 --- a/app/views/events/_view_buttons.html.erb +++ b/app/views/events/_view_buttons.html.erb @@ -1,3 +1,5 @@ +<%# locals: (view_object:) %> +
- <%= render "time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/events/podium.html.erb b/app/views/events/podium.html.erb index ebdd3c180..d28e5c288 100644 --- a/app/views/events/podium.html.erb +++ b/app/views/events/podium.html.erb @@ -18,7 +18,7 @@ - <%= render "time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %> diff --git a/app/views/events/spread.html.erb b/app/views/events/spread.html.erb index 09058f12d..450e2b299 100644 --- a/app/views/events/spread.html.erb +++ b/app/views/events/spread.html.erb @@ -18,7 +18,7 @@ - <%= render "time_and_course_info" %> + <%= render partial: "events/time_and_course_info", locals: { presenter: @presenter } %>