diff --git a/app/controllers/admin/milestones_controller.rb b/app/controllers/admin/milestones_controller.rb index 13a277957..fe71b57b1 100644 --- a/app/controllers/admin/milestones_controller.rb +++ b/app/controllers/admin/milestones_controller.rb @@ -1,5 +1,6 @@ class Admin::MilestonesController < Admin::BaseController include Translatable + include ImageAttributes before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy] before_action :load_milestone, only: [:edit, :update, :destroy] @@ -41,7 +42,6 @@ class Admin::MilestonesController < Admin::BaseController private def milestone_params - image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] attributes = [:publication_date, :status_id, translation_params(Milestone), diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 327527873..91a01988e 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -1,5 +1,6 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController include Translatable + include ImageAttributes load_and_authorize_resource before_action :load_search, only: [:search_booths, :search_officers] @@ -61,7 +62,6 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController end def poll_params - image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :results_enabled, :stats_enabled, geozone_ids: [], image_attributes: image_attributes] diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb index 6dc573131..eb1e6ba79 100644 --- a/app/controllers/admin/widget/cards_controller.rb +++ b/app/controllers/admin/widget/cards_controller.rb @@ -1,5 +1,6 @@ class Admin::Widget::CardsController < Admin::BaseController include Translatable + include ImageAttributes def new if header_card? @@ -41,8 +42,6 @@ class Admin::Widget::CardsController < Admin::BaseController private def card_params - image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] - params.require(:widget_card).permit( :link_url, :button_text, :button_url, :alignment, :header, :site_customization_page_id, :columns, diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 043547088..73c127db4 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -4,6 +4,7 @@ module Budgets include FeatureFlags include CommentableActions include FlagActions + include ImageAttributes before_action :authenticate_user!, except: [:index, :show, :json_data] @@ -130,7 +131,7 @@ module Budgets params.require(:budget_investment) .permit(:title, :description, :heading_id, :tag_list, :organization_name, :location, :terms_of_service, :skip_map, - image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], + image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], map_location_attributes: [:latitude, :longitude, :zoom]) end diff --git a/app/controllers/concerns/image_attributes.rb b/app/controllers/concerns/image_attributes.rb new file mode 100644 index 000000000..a46128c4c --- /dev/null +++ b/app/controllers/concerns/image_attributes.rb @@ -0,0 +1,8 @@ +module ImageAttributes + extend ActiveSupport::Concern + + def image_attributes + [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] + end + +end diff --git a/app/controllers/legislation/proposals_controller.rb b/app/controllers/legislation/proposals_controller.rb index eb5ce4e2f..57f4818ad 100644 --- a/app/controllers/legislation/proposals_controller.rb +++ b/app/controllers/legislation/proposals_controller.rb @@ -1,6 +1,7 @@ class Legislation::ProposalsController < Legislation::BaseController include CommentableActions include FlagActions + include ImageAttributes before_action :parse_tag_filter, only: :index before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] @@ -54,7 +55,7 @@ class Legislation::ProposalsController < Legislation::BaseController params.require(:legislation_proposal).permit(:legislation_process_id, :title, :question, :summary, :description, :video_url, :tag_list, :terms_of_service, :geozone_id, - image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], + image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id]) end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index fe0599eab..5358571de 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -2,6 +2,7 @@ class ProposalsController < ApplicationController include FeatureFlags include CommentableActions include FlagActions + include ImageAttributes before_action :parse_tag_filter, only: :index before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] @@ -92,7 +93,7 @@ class ProposalsController < ApplicationController def proposal_params params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, :skip_map, - image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], + image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], map_location_attributes: [:latitude, :longitude, :zoom]) end