class Admin::SignaturesController < Admin::AdminController - Admin::SignaturesController assumes too much for instance variable '@petition'
- Admin::SignaturesController assumes too much for instance variable '@signature'
- Admin::SignaturesController has no descriptive comment
- Admin::SignaturesController has at least 18 methods
include BulkVerification
before_action :fetch_petition, if: :petition_scope?
before_action :fetch_signature, except: [:index, :bulk_validate, :bulk_invalidate, :bulk_subscribe, :bulk_unsubscribe, :bulk_destroy]
before_action :fetch_signatures, only: [:index]
helper_method :search_params
def index
respond_to do |format|
format.html
end
end
def bulk_validate
begin
scope.validate!(selected_ids, force: true)
redirect_to index_url(search_params), notice: :signatures_validated
rescue StandardError => e - Admin::SignaturesController#bulk_validate has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(search_params), alert: :signatures_not_validated
end
end
def validate
begin
@signature.validate!(force: true)
redirect_to index_url(search_params), notice: :signature_validated
rescue StandardError => e - Admin::SignaturesController#validate has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(search_params), alert: :signature_not_validated
end
end
def bulk_invalidate -
begin
scope.invalidate!(selected_ids)
redirect_to index_url(search_params), notice: :signatures_invalidated
rescue StandardError => e - Admin::SignaturesController#bulk_invalidate has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(search_params), alert: :signatures_not_invalidated
end
end
def invalidate
begin
@signature.invalidate!
redirect_to index_url(search_params), notice: :signature_invalidated
rescue StandardError => e - Admin::SignaturesController#invalidate has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(q: @signature.email), alert: :signature_not_invalidated
end
end
def bulk_destroy -
begin
scope.destroy!(selected_ids)
redirect_to index_url(search_params), notice: :signatures_deleted
rescue StandardError => e - Admin::SignaturesController#bulk_destroy has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(search_params), alert: :signatures_not_deleted
end
end
def destroy -
if @signature.destroy
redirect_to index_url(search_params), notice: :signature_deleted
else
redirect_to index_url(search_params), alert: :signature_not_deleted
end
end
def bulk_subscribe -
begin
scope.subscribe!(selected_ids)
redirect_to index_url(search_params), notice: :signatures_subscribed
rescue StandardError => e - Admin::SignaturesController#bulk_subscribe has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(search_params), alert: :signatures_not_subscribed
end
end
def subscribe -
if @signature.update(notify_by_email: true)
redirect_to admin_signatures_url(search_params), notice: :signature_subscribed -
else
redirect_to admin_signatures_url(search_params), alert: :signature_not_subscribed -
end
end
def bulk_unsubscribe -
begin
scope.unsubscribe!(selected_ids)
redirect_to index_url(search_params), notice: :signatures_unsubscribed -
rescue StandardError => e - Admin::SignaturesController#bulk_unsubscribe has the variable name 'e'
Appsignal.send_exception e
redirect_to index_url(search_params), alert: :signatures_not_unsubscribed -
end
end
def unsubscribe -
if @signature.update(notify_by_email: false)
redirect_to index_url(search_params), notice: :signature_unsubscribed
else
redirect_to index_url(search_params), alert: :signature_not_unsubscribed
end
end
private
def petition_scope?
params.key?(:petition_id)
end
def fetch_petition
@petition = Petition.find(params[:petition_id])
end
def scope
params.key?(:petition_id) ? @petition.signatures : Signature
end
def fetch_signatures
@signatures = scope.search(params[:q], search_params)
end
def fetch_signature
@signature = scope.find(params[:id])
end
def search_params
params.slice(:q, :page, :state, :window)
end
def index_url(*args)
if petition_scope?
admin_petition_signatures_url(*args)
else
admin_signatures_url(*args)
end
end
end