Extract method to redirect keeping query params
This commit is contained in:
@@ -15,14 +15,14 @@ class Admin::HiddenBudgetInvestmentsController < Admin::BaseController
|
||||
|
||||
def confirm_hide
|
||||
@investment.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@investment.restore(recursive: true)
|
||||
@investment.ignore_flag
|
||||
Activity.log(current_user, :restore, @investment)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -10,14 +10,14 @@ class Admin::HiddenCommentsController < Admin::BaseController
|
||||
|
||||
def confirm_hide
|
||||
@comment.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@comment.restore(recursive: true)
|
||||
@comment.ignore_flag
|
||||
Activity.log(current_user, :restore, @comment)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -13,14 +13,14 @@ class Admin::HiddenDebatesController < Admin::BaseController
|
||||
|
||||
def confirm_hide
|
||||
@debate.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@debate.restore!(recursive: true)
|
||||
@debate.ignore_flag
|
||||
Activity.log(current_user, :restore, @debate)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -14,14 +14,14 @@ class Admin::HiddenProposalsController < Admin::BaseController
|
||||
|
||||
def confirm_hide
|
||||
@proposal.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@proposal.restore(recursive: true)
|
||||
@proposal.ignore_flag
|
||||
Activity.log(current_user, :restore, @proposal)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -15,13 +15,13 @@ class Admin::HiddenUsersController < Admin::BaseController
|
||||
|
||||
def confirm_hide
|
||||
@user.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@user.restore
|
||||
Activity.log(current_user, :restore, @user)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -19,11 +19,11 @@ class Admin::OrganizationsController < Admin::BaseController
|
||||
|
||||
def verify
|
||||
@organization.verify
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def reject
|
||||
@organization.reject
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,14 +12,14 @@ class Admin::ProposalNotificationsController < Admin::BaseController
|
||||
|
||||
def confirm_hide
|
||||
@proposal_notification.confirm_hide
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
def restore
|
||||
@proposal_notification.restore
|
||||
@proposal_notification.ignore_flag
|
||||
Activity.log(current_user, :restore, @proposal_notification)
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -120,4 +120,8 @@ class ApplicationController < ActionController::Base
|
||||
def current_budget
|
||||
Budget.current
|
||||
end
|
||||
|
||||
def redirect_with_query_params_to(options, response_status = {})
|
||||
redirect_to request.query_parameters.merge(options), response_status
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ module ModerateActions
|
||||
User.where(id: author_ids).accessible_by(current_ability, :block).each { |user| block_user user }
|
||||
end
|
||||
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
redirect_with_query_params_to(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -9,7 +9,7 @@ class Moderation::UsersController < Moderation::BaseController
|
||||
def hide_in_moderation_screen
|
||||
block_user
|
||||
|
||||
redirect_to request.query_parameters.merge(action: :index), notice: I18n.t("moderation.users.notice_hide")
|
||||
redirect_with_query_params_to({ action: :index }, { notice: I18n.t("moderation.users.notice_hide") })
|
||||
end
|
||||
|
||||
def hide
|
||||
|
||||
Reference in New Issue
Block a user