Extract concern to share hidden content code
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
class Admin::HiddenBudgetInvestmentsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
include Admin::HiddenContent
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
before_action :load_investment, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@investments = Budget::Investment.only_hidden.send(@current_filter)
|
||||
.order(hidden_at: :desc)
|
||||
.page(params[:page])
|
||||
@investments = hidden_content(Budget::Investment.all)
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
class Admin::HiddenCommentsController < Admin::BaseController
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide]
|
||||
include Admin::HiddenContent
|
||||
|
||||
before_action :load_comment, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@comments = Comment.not_valuations.only_hidden.with_visible_author
|
||||
.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||
@comments = hidden_content(Comment.not_valuations).with_visible_author
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
class Admin::HiddenDebatesController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
include Admin::HiddenContent
|
||||
|
||||
feature_flag :debates
|
||||
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
|
||||
before_action :load_debate, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@debates = Debate.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||
@debates = hidden_content(Debate.all)
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
class Admin::HiddenProposalNotificationsController < Admin::BaseController
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
include Admin::HiddenContent
|
||||
|
||||
before_action :load_proposal, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@proposal_notifications = ProposalNotification.only_hidden
|
||||
.send(@current_filter)
|
||||
.order(hidden_at: :desc)
|
||||
.page(params[:page])
|
||||
@proposal_notifications = hidden_content(ProposalNotification.all)
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
class Admin::HiddenProposalsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
include Admin::HiddenContent
|
||||
|
||||
feature_flag :proposals
|
||||
|
||||
before_action :load_proposal, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@proposals = Proposal.only_hidden.send(@current_filter).order(hidden_at: :desc)
|
||||
.page(params[:page])
|
||||
@proposals = hidden_content(Proposal.all)
|
||||
end
|
||||
|
||||
def confirm_hide
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class Admin::HiddenUsersController < Admin::BaseController
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
include Admin::HiddenContent
|
||||
|
||||
before_action :load_user, only: [:confirm_hide, :restore]
|
||||
|
||||
def index
|
||||
@users = User.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||
@users = hidden_content(User.all)
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
11
app/controllers/concerns/admin/hidden_content.rb
Normal file
11
app/controllers/concerns/admin/hidden_content.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module Admin::HiddenContent
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
end
|
||||
|
||||
def hidden_content(relation)
|
||||
relation.only_hidden.send(@current_filter).order(hidden_at: :desc).page(params[:page])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user