Merge pull request #3170 from rogelio-o/feature/3153
Refactor images attributes
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
class Admin::MilestonesController < Admin::BaseController
|
class Admin::MilestonesController < Admin::BaseController
|
||||||
include Translatable
|
include Translatable
|
||||||
|
include ImageAttributes
|
||||||
|
|
||||||
before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy]
|
before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||||
before_action :load_milestone, only: [:edit, :update, :destroy]
|
before_action :load_milestone, only: [:edit, :update, :destroy]
|
||||||
@@ -41,7 +42,6 @@ class Admin::MilestonesController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def milestone_params
|
def milestone_params
|
||||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
|
||||||
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||||
attributes = [:publication_date, :status_id,
|
attributes = [:publication_date, :status_id,
|
||||||
translation_params(Milestone),
|
translation_params(Milestone),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Admin::Poll::PollsController < Admin::Poll::BaseController
|
class Admin::Poll::PollsController < Admin::Poll::BaseController
|
||||||
include Translatable
|
include Translatable
|
||||||
|
include ImageAttributes
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
before_action :load_search, only: [:search_booths, :search_officers]
|
before_action :load_search, only: [:search_booths, :search_officers]
|
||||||
@@ -61,7 +62,6 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def poll_params
|
def poll_params
|
||||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
|
||||||
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :results_enabled,
|
attributes = [:name, :starts_at, :ends_at, :geozone_restricted, :results_enabled,
|
||||||
:stats_enabled, geozone_ids: [],
|
:stats_enabled, geozone_ids: [],
|
||||||
image_attributes: image_attributes]
|
image_attributes: image_attributes]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Admin::Widget::CardsController < Admin::BaseController
|
class Admin::Widget::CardsController < Admin::BaseController
|
||||||
include Translatable
|
include Translatable
|
||||||
|
include ImageAttributes
|
||||||
|
|
||||||
def new
|
def new
|
||||||
if header_card?
|
if header_card?
|
||||||
@@ -41,8 +42,6 @@ class Admin::Widget::CardsController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def card_params
|
def card_params
|
||||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
|
||||||
|
|
||||||
params.require(:widget_card).permit(
|
params.require(:widget_card).permit(
|
||||||
:link_url, :button_text, :button_url, :alignment, :header, :site_customization_page_id,
|
:link_url, :button_text, :button_url, :alignment, :header, :site_customization_page_id,
|
||||||
:columns,
|
:columns,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module Budgets
|
|||||||
include FeatureFlags
|
include FeatureFlags
|
||||||
include CommentableActions
|
include CommentableActions
|
||||||
include FlagActions
|
include FlagActions
|
||||||
|
include ImageAttributes
|
||||||
|
|
||||||
before_action :authenticate_user!, except: [:index, :show, :json_data]
|
before_action :authenticate_user!, except: [:index, :show, :json_data]
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ module Budgets
|
|||||||
params.require(:budget_investment)
|
params.require(:budget_investment)
|
||||||
.permit(:title, :description, :heading_id, :tag_list,
|
.permit(:title, :description, :heading_id, :tag_list,
|
||||||
:organization_name, :location, :terms_of_service, :skip_map,
|
: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],
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
||||||
map_location_attributes: [:latitude, :longitude, :zoom])
|
map_location_attributes: [:latitude, :longitude, :zoom])
|
||||||
end
|
end
|
||||||
|
|||||||
8
app/controllers/concerns/image_attributes.rb
Normal file
8
app/controllers/concerns/image_attributes.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module ImageAttributes
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def image_attributes
|
||||||
|
[:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
class Legislation::ProposalsController < Legislation::BaseController
|
class Legislation::ProposalsController < Legislation::BaseController
|
||||||
include CommentableActions
|
include CommentableActions
|
||||||
include FlagActions
|
include FlagActions
|
||||||
|
include ImageAttributes
|
||||||
|
|
||||||
before_action :parse_tag_filter, only: :index
|
before_action :parse_tag_filter, only: :index
|
||||||
before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary]
|
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,
|
params.require(:legislation_proposal).permit(:legislation_process_id, :title,
|
||||||
:question, :summary, :description, :video_url, :tag_list,
|
:question, :summary, :description, :video_url, :tag_list,
|
||||||
:terms_of_service, :geozone_id,
|
: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])
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class ProposalsController < ApplicationController
|
|||||||
include FeatureFlags
|
include FeatureFlags
|
||||||
include CommentableActions
|
include CommentableActions
|
||||||
include FlagActions
|
include FlagActions
|
||||||
|
include ImageAttributes
|
||||||
|
|
||||||
before_action :parse_tag_filter, only: :index
|
before_action :parse_tag_filter, only: :index
|
||||||
before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary]
|
before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary]
|
||||||
@@ -92,7 +93,7 @@ class ProposalsController < ApplicationController
|
|||||||
def proposal_params
|
def proposal_params
|
||||||
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
|
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
|
||||||
:responsible_name, :tag_list, :terms_of_service, :geozone_id, :skip_map,
|
: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],
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy],
|
||||||
map_location_attributes: [:latitude, :longitude, :zoom])
|
map_location_attributes: [:latitude, :longitude, :zoom])
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user