Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ group :development do
gem "rubocop-rails-omakase", require: false
end

group :test do
gem "launchy"
end

group :development, :test do
gem "better_errors"
# gem "binding_of_caller" # Temporarily commented - doesn't support Ruby 4.0.1
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/analytics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def index

@most_printed_workshops = decorate_with_counts(most_printed_for_model(Workshop, time_scope), :print_count)
@most_printed_resources = decorate_with_counts(most_printed_for_model(Resource, time_scope), :print_count)
# @most_printed_community_news = decorate_with_counts(most_printed_for_model(CommunityNews, time_scope), :print_count)
# @most_printed_stories = decorate_with_counts(most_printed_for_model(Story, time_scope), :print_count)
@most_printed_community_news = decorate_with_counts(most_printed_for_model(CommunityNews, time_scope), :print_count)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sidequest: these were missing from the view

@most_printed_stories = decorate_with_counts(most_printed_for_model(Story, time_scope), :print_count)
# @most_printed_workshop_variations = decorate_with_counts(most_printed_for_model(WorkshopVariation, time_scope), :print_count)
# @most_printed_quotes = decorate_with_counts(most_printed_for_model(Quote, time_scope), :print_count)
# @most_printed_tutorials = decorate_with_counts(most_printed_for_model(Tutorial, time_scope), :print_count)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/banners_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def set_banner
# Strong parameters
def banner_params
params.require(:banner).permit(
:content, :show, :created_by_id, :updated_by_id
:content, :published, :created_by_id, :updated_by_id
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
unfiltered = Category.includes(:category_type).joins(:category_type)
filtered = unfiltered.category_type_id(params[:category_type_id])
.category_name(params[:category_name])
.published_search(params[:published_search])
.published(params[:published])
.order(Arel.sql("category_types.name, categories.position, categories.name"))
@categories = filtered.paginate(page: params[:page], per_page: per_page)

Expand Down
1 change: 1 addition & 0 deletions app/controllers/community_news_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class CommunityNewsController < ApplicationController
include ExternallyRedirectable, AssetUpdatable, AhoyTracking
skip_before_action :authenticate_user!, only: [ :index, :show ]
before_action :set_community_news, only: [ :show, :edit, :update, :destroy ]

def index
Expand Down
13 changes: 6 additions & 7 deletions app/controllers/concerns/ahoy_tracking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ def track_tagging_browse(grouped_results)

return if sectors.blank? && categories.blank?

total_results = grouped_results.values.sum { |r| r.respond_to?(:total_entries) ? r.total_entries : r.size }

# total_results = grouped_results.values.sum { |r| r.respond_to?(:total_entries) ? r.total_entries : r.size }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sidequest: turning ahoy totals off for now bc was hitting an error

ahoy.track "browse.taggings", {
sectors: sectors,
categories: categories,
result_count: total_results,
result_breakdown: grouped_results.transform_values do |r|
r.respond_to?(:total_entries) ? r.total_entries : r.size
end,
page_result_count: grouped_results.values.sum(&:size)
# result_count: total_results,
# result_breakdown: grouped_results.transform_values do |r|
# r.respond_to?(:total_entries) ? r.total_entries : r.size
# end,
page_result_count: grouped_results.values.sum(&:size) # only loaded page
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/event_registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def destroy

# Optional hooks for setting variables for forms or index
def set_form_variables
@events = Event.where(inactive: false).order(:start_date)
@events = Event.where(published: true).order(:start_date)
@registrants = User.active.order(:last_name, :first_name)
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class EventsController < ApplicationController
include AhoyTracking, AssetUpdatable
skip_before_action :authenticate_user!, only: %i[ index show]
skip_before_action :authenticate_user!, only: [ :index, :show ]
before_action :set_event, only: %i[ show edit update destroy ]

def index
Expand Down Expand Up @@ -93,7 +93,7 @@ def event_params
:featured,
:start_date, :end_date,
:registration_close_date,
:inactive,
:published,
:publicly_visible,
:publicly_featured
)
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/facilitators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def set_form_variables
@facilitator.user.project_users.first || @facilitator.user.project_users.build
end
projects = if current_user.super_user?
Project.active
Project.published
else
current_user.projects
end
Expand Down Expand Up @@ -122,6 +122,7 @@ def facilitator_params
:profile_show_workshop_variations,
:profile_show_workshops,
:profile_show_workshop_logs,
:published,
:member_since,
:linked_in_url,
:facebook_url,
Expand All @@ -142,6 +143,7 @@ def facilitator_params
:district,
:locality,
:phone,
:inactive,
:_destroy
],
contact_methods_attributes: [
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/faqs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
class FaqsController < ApplicationController
skip_before_action :authenticate_user!, only: [ :index, :show ]
before_action :set_faq, only: [ :show, :edit, :update, :destroy ]

def index
faqs = current_user.super_user? ? Faq.all : Faq.active
@faqs = faqs.search_by_params(params.to_unsafe_h.slice("query", "inactive"))
faqs = current_user&.super_user? ? Faq.all : (current_user ? Faq.published : Faq.publicly_visible)
@faqs = faqs.search_by_params(params.to_unsafe_h.slice("query", "published"))
.by_position
.page(params[:page])
end
Expand Down Expand Up @@ -59,6 +60,6 @@ def set_faq

# Strong parameters
def faq_params
params.require(:faq).permit(:question, :answer, :inactive, :position, :publicly_visible)
params.require(:faq).permit(:question, :answer, :position, :published, :publicly_visible)
end
end
2 changes: 1 addition & 1 deletion app/controllers/monthly_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def load_agencies

def render_form
@workshop_list = Workshop.created_by_id(current_user.id)
.where(inactive: false, windows_type: 3)
.where(published: true, windows_type: 3)
.order(title: :asc)

build_month_and_year
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/quotes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def quote_params
params.require(:quote).permit(
:age,
:gender,
:inactive,
:published,
:quote,
:speaker_name,
:workshop_id,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def edit

def edit_story
@workshop_list = Workshop.created_by_id(current_user.id)
.where(inactive: false, windows_type: 3)
.where(published: true, windows_type: 3)
.order(title: :asc)

@report = Report.find(params[:id])
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/resources_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class ResourcesController < ApplicationController
include ExternallyRedirectable, AssetUpdatable, AhoyTracking
skip_before_action :authenticate_user!, only: [ :index, :show ]

def index
authorize!
Expand Down Expand Up @@ -139,7 +140,7 @@ def resource_id_param

def resource_params
params.require(:resource).permit(
:rhino_text, :kind, :male, :female, :title, :featured, :inactive, :publicly_visible, :publicly_featured, :url,
:rhino_text, :kind, :male, :female, :title, :featured, :published, :publicly_visible, :publicly_featured, :url,
:agency, :author, :filemaker_code, :windows_type_id, :position,
categorizable_items_attributes: [ :id, :category_id, :_destroy ], category_ids: [],
sectorable_items_attributes: [ :id, :sector_id, :is_leader, :_destroy ], sector_ids: []
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/sectors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def index
per_page = params[:number_of_items_per_page].presence || 25
unfiltered = Sector.all
filtered = unfiltered.sector_name(params[:sector_name])
.published_search(params[:published_search])
.order(:name)
.published(params[:published])
.order(:name)
@sectors = filtered.paginate(page: params[:page], per_page: per_page)

@count_display = if filtered.count == unfiltered.count
Expand Down
1 change: 1 addition & 0 deletions app/controllers/stories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class StoriesController < ApplicationController
include ExternallyRedirectable, AssetUpdatable, AhoyTracking
skip_before_action :authenticate_user!, only: [ :index, :show ]
before_action :set_story, only: [ :show, :edit, :update, :destroy ]

def index
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/taggings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class TaggingsController < ApplicationController
include AhoyTracking

def index
@sector_names = params[:sector_names].to_s
@category_names = params[:category_names].to_s
@sector_names = params[:sector_names]
@category_names = params[:category_names]

number_of_items_per_page = params[:number_of_items_per_page].present? ? params[:number_of_items_per_page].to_i : 9
pages = {
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/tutorials_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class TutorialsController < ApplicationController
include AhoyTracking
skip_before_action :authenticate_user!, only: [ :index, :show ]
before_action :set_tutorial, only: [ :show, :edit, :update, :destroy ]

def index
per_page = params[:number_of_items_per_page].presence || 25
unfiltered = current_user.super_user? ? Tutorial.all : Tutorial.published
unfiltered = current_user&.super_user? ? Tutorial.all : current_user ? Tutorial.published : Tutorial.publicly_visible
filtered = unfiltered.search_by_params(params)
@count_display = filtered.count == unfiltered.count ? unfiltered.count : "#{filtered.count}/#{unfiltered.count}"
@tutorials = filtered.order(:position).paginate(page: params[:page], per_page: per_page).decorate
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def set_facilitator
def set_form_variables
set_facilitator
@user.project_users.first || @user.project_users.build
projects = if current_user.super_user?
Project.active
projects = if current_user.admin?
Project.published
else
current_user.projects
end
Expand All @@ -177,7 +177,7 @@ def user_params
:phone, :phone2, :phone3, :birthday, :best_time_to_call, :comment,
:notes, :primary_address, :avatar, :subscribecode,
:agency_id, :facilitator_id, :created_by_id, :updated_by_id,
:confirmed, :inactive, :super_user, :legacy, :legacy_id,
:confirmed, :published, :super_user, :legacy, :legacy_id,
project_users_attributes: [ :id, :project_id, :position, :title, :inactive, :_destroy ]
)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/workshop_logs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def set_index_variables # needs to not be private
.order(:last_name, :first_name)
@projects = if current_user.super_user?
# Project.where(id: @workshop_logs_unpaginated.pluck(:project_id)).order(:name)
Project.active.order(:name)
Project.published.order(:name)
else
current_user.projects.order(:name)
end
Expand Down Expand Up @@ -176,7 +176,7 @@ def set_form_variables
form = FormBuilder.where(windows_type_id: @windows_type_id)
.first&.forms.first # because there's only one form per form_builder
if form
@report_field_answers = form.form_fields.active.order(:position).map do |field|
@report_field_answers = form.form_fields.published.order(:position).map do |field|
@workshop_log.report_form_field_answers.find_or_initialize_by(form_field: field)
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/workshop_variations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
WorkshopVariation
.includes(:workshop)
.joins(:workshop)
.where(workshops: { inactive: false })
.where(workshops: { published: true })
.order("workshop_variations.created_at DESC, workshops.title, workshop_variations.name")
.paginate(page: params[:page], per_page: 25)
.decorate
Expand Down Expand Up @@ -87,7 +87,7 @@ def set_form_variables

def workshop_variation_params
params.require(:workshop_variation).permit(
[ :name, :code, :inactive, :position,
[ :name, :code, :published, :position,
:youtube_url, :created_by_id, :workshop_id
]
)
Expand Down
10 changes: 6 additions & 4 deletions app/controllers/workshops_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class WorkshopsController < ApplicationController
include AssetUpdatable, AhoyTracking
skip_before_action :authenticate_user!, only: [ :index, :show ]

def index
@category_types = CategoryType.published.order(:name).decorate
@sectors = Sector.published
@windows_types = WindowsType.all

if turbo_frame_request?
search_service = WorkshopSearchService.new(params, super_user: current_user.super_user?).call
search_service = WorkshopSearchService.new(params, user: current_user).call
@sort = search_service.sort

track_index_intent(Workshop, search_service.workshops, params)
Expand Down Expand Up @@ -189,9 +191,9 @@ def search

def set_show
@quotes = Quote.where(workshop_id: @workshop.id).active
@leader_spotlights = @workshop.associated_resources.leader_spotlights.where(inactive: false)
@leader_spotlights = @workshop.associated_resources.leader_spotlights.where(published: true)
@workshop_variations = @workshop.workshop_variations.active
@sectors = @workshop.sectorable_items.published.map { |item| item.sector if item.sector.published }.compact if @workshop.sectorable_items.any?
@sectors = @workshop.sectorable_items.published.map { |item| item.sector if item.sector.published? }.compact if @workshop.sectorable_items.any?
end


Expand Down Expand Up @@ -239,7 +241,7 @@ def view_all_workshops?

def workshop_params
params.require(:workshop).permit(
:title, :featured, :inactive,
:title, :featured, :published,
:full_name, :user_id, :windows_type_id, :workshop_idea_id,
:month, :year,
:publicly_visible,
Expand Down
4 changes: 0 additions & 4 deletions app/decorators/community_news_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ def detail(length: nil)
def external_url
object.reference_url
end

def inactive?
!published?
end
end
4 changes: 0 additions & 4 deletions app/decorators/facilitator_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ def default_display_image
"missing.png"
end

def inactive?
!user ? false : user&.inactive?
end

def primary_asset
avatar
end
Expand Down
4 changes: 0 additions & 4 deletions app/decorators/story_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ def external_url
object.website_url
end

def inactive?
!published?
end

def workshop_title
workshop&.title || external_workshop_title
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/admin_cards_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def reference_cards
[
model_card(:categories, icon: "🗂️",
intensity: 100,
params: { published_search: true }),
params: { published: true }),
model_card(:sectors, icon: "🏭",
intensity: 100,
title: "Service populations",
params: { published_search: true }),
params: { published: true }),
custom_card("Project statuses", project_statuses_path, icon: "🧮", color: :emerald, intensity: 100),
custom_card("Windows types", windows_types_path, icon: "🪟")
]
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/analytics_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def print_button(record,
icon_class: "fas fa-print",
button_text: nil,
title: "Print",
image_toggle: false)
image_toggle: false)
model = record.respond_to?(:object) ? record.object : record

resolved_type =
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/tag_matrix_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def tag_count_for(model, tag:, type:)
model.category_names(tag.name)
end

scope.published.count
scope.published.unscope(:group).count
end

def tag_link_for(model, tag:, type:)
Expand Down
6 changes: 2 additions & 4 deletions app/helpers/title_display_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ def title_with_badges(record, font_size: "text-lg", record_title: nil,
fragments = []

# --- Hidden badge ---
if show_hidden_badge && controller_name != "dashboard" && (
record.respond_to?(:inactive?) && record.inactive? && controller_name != "dashboard" ||
record.respond_to?(:published?) && !record.published?)
if show_hidden_badge && controller_name != "dashboard" && record.respond_to?(:published?) && !record.published?
fragments << content_tag(
:span,
content_tag(:i, "", class: "fa-solid fa-eye-slash mr-1") + " Hidden",
content_tag(:i, "", class: "fa-solid fa-eye-slash mr-1") + " Unpublished",
class: "inline-flex items-center px-2 py-0.5 rounded-full
text-sm font-medium bg-blue-100 text-gray-600 whitespace-nowrap"
)
Expand Down
Loading