diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 382ad4d1d..c1f873541 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -39,7 +39,7 @@ def admin bg_color: "bg-gray-50", text_color: "text-gray-800" }, { title: "Event Registrations", path: event_registrations_path, icon: "🎟️", bg_color: "bg-blue-100", text_color: "text-blue-800" }, - { title: "!!!Quotes", path: authenticated_root_path, icon: "💬", + { title: "Quotes", path: quotes_path, icon: "💬", bg_color: "bg-gray-50", text_color: "text-gray-800" }, { title: "Story Ideas", path: story_ideas_path, icon: "✍️️", bg_color: "bg-rose-100", text_color: "text-rose-800" }, diff --git a/app/decorators/quote_decorator.rb b/app/decorators/quote_decorator.rb index e2c9c3e81..25ccc8837 100644 --- a/app/decorators/quote_decorator.rb +++ b/app/decorators/quote_decorator.rb @@ -13,7 +13,7 @@ def attribution name = speaker_name.presence || "anonymous" details = [] - details << "#{age}yrs" if age.present? + details << "#{age.gsub("years","").gsub("yrs","")} yrs" if age.present? details << gender if gender.present? if details.any? diff --git a/app/models/report.rb b/app/models/report.rb index 773a3e151..130930616 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -6,8 +6,10 @@ class Report < ApplicationRecord has_one :form, as: :owner has_many :bookmarks, as: :bookmarkable, dependent: :destroy has_many :notifications, as: :noticeable, dependent: :destroy - has_many :quotable_item_quotes, as: :quotable, dependent: :destroy - has_many :report_form_field_answers, dependent: :destroy + has_many :quotable_item_quotes, as: :quotable, dependent: :nullify, inverse_of: :quotable + has_many :report_form_field_answers, + foreign_key: :report_id, inverse_of: :report, + dependent: :destroy has_many :sectorable_items, as: :sectorable, dependent: :destroy # Images has_one_attached :image # old paperclip -- TODO convert these to MainImage records @@ -22,14 +24,20 @@ class Report < ApplicationRecord # has_many through has_many :form_fields, through: :form - has_many :quotes, through: :quotable_item_quotes, dependent: :destroy + has_many :all_quotable_item_quotes, + ->(wl) { where(quotable_id: wl.id, + quotable_type: %w[WorkshopLog Report]) }, # needed bc some are stored w type Report + class_name: "QuotableItemQuote", + inverse_of: :quotable + has_many :quotes, through: :all_quotable_item_quotes, dependent: :nullify has_many :sectors, through: :sectorable_items, dependent: :destroy # Nested attributes accepts_nested_attributes_for :media_files, allow_destroy: true, reject_if: :all_blank accepts_nested_attributes_for :main_image, allow_destroy: true, reject_if: :all_blank accepts_nested_attributes_for :gallery_images, allow_destroy: true, reject_if: :all_blank - accepts_nested_attributes_for :quotable_item_quotes + accepts_nested_attributes_for :all_quotable_item_quotes, allow_destroy: true, reject_if: :all_blank + accepts_nested_attributes_for :quotable_item_quotes, allow_destroy: true, reject_if: :all_blank accepts_nested_attributes_for :report_form_field_answers, reject_if: proc { |object| object["_create"].to_i == 0 && object["answer"].nil? } diff --git a/app/models/workshop_log.rb b/app/models/workshop_log.rb index def955bfa..495810ce5 100644 --- a/app/models/workshop_log.rb +++ b/app/models/workshop_log.rb @@ -1,35 +1,11 @@ class WorkshopLog < Report belongs_to :workshop - belongs_to :user - belongs_to :project - has_many :quotable_item_quotes, as: :quotable, dependent: :nullify, inverse_of: :quotable - has_many :all_quotable_item_quotes, - ->(wl) { where(quotable_id: wl.id, - quotable_type: %w[WorkshopLog Report]) }, # needed bc some are stored w type Report - class_name: "QuotableItemQuote", - inverse_of: :quotable - has_many :quotes, through: :all_quotable_item_quotes - has_many :report_form_field_answers, - foreign_key: :report_id, inverse_of: :report, - dependent: :destroy - # Image associations - has_many :media_files, dependent: :destroy # TODO - convert these to GalleryImages - has_many :gallery_images, -> { where(type: "Images::GalleryImage") }, - as: :owner, class_name: "Images::GalleryImage", dependent: :destroy - - # Nested attributes - accepts_nested_attributes_for :gallery_images, allow_destroy: true, reject_if: :all_blank - accepts_nested_attributes_for :quotable_item_quotes, allow_destroy: true, - reject_if: ->(attributes) { false } # allow empty - accepts_nested_attributes_for :all_quotable_item_quotes, allow_destroy: true, reject_if: :all_blank - accepts_nested_attributes_for :report_form_field_answers, allow_destroy: true, - reject_if: ->(attributes) { false } # allow empty # Validations + validates :date, presence: true validates :children_ongoing, :teens_ongoing, :adults_ongoing, :children_first_time, :teens_first_time, :adults_first_time, numericality: { greater_than_or_equal_to: 0, only_integer: true } - validates :date, presence: true # Callbacks after_save :update_owner_and_date diff --git a/app/views/quotes/_form.html.erb b/app/views/quotes/_form.html.erb index f24ec0ab2..26c60e534 100644 --- a/app/views/quotes/_form.html.erb +++ b/app/views/quotes/_form.html.erb @@ -28,17 +28,24 @@