1class Admin::Archived::SignaturesController < Admin::AdminController |
|
2 include BulkVerification |
|
4 before_action :fetch_signature, except: [:index, :bulk_subscribe, :bulk_unsubscribe, :bulk_destroy] |
|
5 before_action :fetch_signatures, only: [:index] |
|
7 helper_method :search_params |
|
9 def index |
|
10 respond_to do |format| |
|
11 format.html
|
|
12 end |
|
13 end |
|
15 def bulk_destroy |
|
16 begin |
|
17 ::Archived::Signature.destroy!(selected_ids) |
|
18 redirect_to admin_archived_signatures_url(search_params), notice: :signatures_deleted |
|
19 rescue StandardError => e |
|
20 Appsignal.send_exception e |
|
21 redirect_to admin_archived_signatures_url(search_params), alert: :signatures_not_deleted |
|
22 end |
|
23 end |
|
25 def destroy |
|
26 if @signature.destroy |
|
27 redirect_to admin_archived_signatures_url(search_params), notice: :signature_deleted |
|
28 else |
|
29 redirect_to admin_archived_signatures_url(search_params), alert: :signature_not_deleted |
|
30 end |
|
31 end |
|
33 def bulk_subscribe |
|
34 begin |
|
35 ::Archived::Signature.subscribe!(selected_ids) |
|
36 redirect_to admin_archived_signatures_url(search_params), notice: :signatures_subscribed |
|
37 rescue StandardError => e |
|
38 Appsignal.send_exception e |
|
39 redirect_to admin_archived_signatures_url(search_params), alert: :signatures_not_subscribed |
|
40 end |
|
41 end |
|
43 def subscribe |
|
44 if @signature.update(notify_by_email: true) |
|
45 redirect_to admin_archived_signatures_url(search_params), notice: :signature_subscribed |
|
46 else |
|
47 redirect_to admin_archived_signatures_url(search_params), alert: :signature_not_subscribed |
|
48 end |
|
49 end |
|
51 def bulk_unsubscribe |
|
52 begin |
|
53 ::Archived::Signature.unsubscribe!(selected_ids) |
|
54 redirect_to admin_archived_signatures_url(search_params), notice: :signatures_unsubscribed |
|
55 rescue StandardError => e |
|
56 Appsignal.send_exception e |
|
57 redirect_to admin_archived_signatures_url(search_params), alert: :signatures_not_unsubscribed |
|
58 end |
|
59 end |
|
61 def unsubscribe |
|
62 if @signature.update(notify_by_email: false) |
|
63 redirect_to admin_archived_signatures_url(search_params), notice: :signature_unsubscribed |
|
64 else |
|
65 redirect_to admin_archived_signatures_url(search_params), alert: :signature_not_unsubscribed |
|
66 end |
|
67 end |
|
69 private
|
|
71 def fetch_signatures |
|
72 @signatures = ::Archived::Signature.search(params[:q], search_params) |
|
73 end |
|
75 def fetch_signature |
|
76 @signature = ::Archived::Signature.find(params[:id]) |
|
77 end |
|
79 def search_params |
|
80 params.slice(:q, :page, :state, :window) |
|
81 end |
|
82end |