Class: Kaui::AuditLogsController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::AuditLogsController
- Defined in:
- app/controllers/kaui/audit_logs_controller.rb
Constant Summary collapse
- OBJECT_WITH_HISTORY =
%w[ACCOUNT ACCOUNT_EMAIL CUSTOM_FIELD PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD TRANSACTION TAG TAG_DEFINITION]
Constants included from EngineControllerUtil
EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary collapse
Methods inherited from EngineController
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user
Instance Method Details
#history ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/kaui/audit_logs_controller.rb', line 43 def history json_response do account_id = params.require(:account_id) object_id = params.require(:object_id) object_type = params.require(:object_type) = audit_logs_with_history = [] error = nil begin if object_type == 'ACCOUNT' account = Kaui::Account::find_by_id_or_key(object_id, false, false, ) audit_logs_with_history = account.audit_logs_with_history() elsif object_type == 'ACCOUNT_EMAIL' account = Kaui::Account::find_by_id_or_key(account_id, false, false, ) audit_logs_with_history = account.email_audit_logs_with_history(object_id, ) elsif object_type == 'CUSTOM_FIELD' audit_logs_with_history = Kaui::CustomField.new({:custom_field_id => object_id}).audit_logs_with_history() elsif object_type == 'PAYMENT_ATTEMPT' audit_logs_with_history = Kaui::Payment::attempt_audit_logs_with_history(object_id, ) elsif object_type == 'PAYMENT' payment = Kaui::Payment::find_by_id(object_id, false, false, ) audit_logs_with_history = payment.audit_logs_with_history() elsif object_type == 'PAYMENT_METHOD' payment_method = Kaui::PaymentMethod::find_by_id(object_id, false, ) audit_logs_with_history = payment_method.audit_logs_with_history() elsif object_type == 'TRANSACTION' audit_logs_with_history = Kaui::Transaction::new({:transaction_id => object_id}).audit_logs_with_history() elsif object_type == 'TAG' audit_logs_with_history = Kaui::Tag.new({:tag_id => object_id}).audit_logs_with_history() elsif object_type == 'TAG_DEFINITION' audit_logs_with_history = Kaui::TagDefinition.new({:id => object_id}).audit_logs_with_history() else error = "Object [#{object_type}] history is not supported." end rescue Exception => e error = e. end { audits: audit_logs_with_history, error: error } end end |
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/kaui/audit_logs_controller.rb', line 4 def index = @account = Kaui::Account::find_by_id_or_key(params.require(:account_id), false, false, ) audit_logs = @account.audit() formatter = lambda do |log| object_id_text = view_context.object_id_popover(log.object_id) if object_with_history?(log.object_type) object_id_text = view_context.link_to(object_id_text, '#showHistoryModal', data: { toggle: 'modal', object_id: log.object_id, object_type: log.object_type, change_date: log.change_date, change_type: log.change_type, account_id: @account.account_id }) end [ log.change_date, object_id_text, log.object_type, log.change_type, log.changed_by, log.reason_code, log.comments, view_context.object_id_popover(log.user_token, 'left') ] end @audit_logs_json = [] audit_logs.each { |page| @audit_logs_json << formatter.call(page) } @audit_logs_json = @audit_logs_json.to_json end |