Extract method to redirect keeping query params

This commit is contained in:
Javi Martín
2019-11-10 13:21:15 +01:00
parent 941fc76884
commit 667797161b
10 changed files with 20 additions and 16 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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