From 8f62a0caa89d87d6d80c170d41c1b5ca1754d54b Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Sat, 27 Feb 2016 23:08:24 +0530 Subject: [PATCH] FEATURE: log backup operation --- app/controllers/admin/backups_controller.rb | 1 + app/models/user_history.rb | 6 ++++-- app/services/staff_action_logger.rb | 6 ++++++ config/locales/client.en.yml | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/backups_controller.rb b/app/controllers/admin/backups_controller.rb index 9ebe489fa70..286d3e6ef95 100644 --- a/app/controllers/admin/backups_controller.rb +++ b/app/controllers/admin/backups_controller.rb @@ -32,6 +32,7 @@ class Admin::BackupsController < Admin::AdminController rescue BackupRestore::OperationRunningError render json: failed_json.merge(message: I18n.t("backup.operation_already_running")) else + StaffActionLogger.new(current_user).log_backup_operation render json: success_json end diff --git a/app/models/user_history.rb b/app/models/user_history.rb index 1ce5021501b..e142d9f5ad7 100644 --- a/app/models/user_history.rb +++ b/app/models/user_history.rb @@ -50,7 +50,8 @@ class UserHistory < ActiveRecord::Base grant_admin: 32, revoke_admin: 33, grant_moderation: 34, - revoke_moderation: 35) + revoke_moderation: 35, + backup_operation: 36) end # Staff actions is a subset of all actions, used to audit actions taken by staff users. @@ -82,7 +83,8 @@ class UserHistory < ActiveRecord::Base :grant_admin, :revoke_admin, :grant_moderation, - :revoke_moderation] + :revoke_moderation, + :backup_operation] end def self.staff_action_ids diff --git a/app/services/staff_action_logger.rb b/app/services/staff_action_logger.rb index 24ce8371836..25666e759f5 100644 --- a/app/services/staff_action_logger.rb +++ b/app/services/staff_action_logger.rb @@ -326,6 +326,12 @@ class StaffActionLogger })) end + def log_backup_operation(opts={}) + UserHistory.create(params(opts).merge({ + action: UserHistory.actions[:backup_operation] + })) + end + private def params(opts=nil) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d160ed2e518..d4d17f0a103 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2354,6 +2354,7 @@ en: revoke_admin: "revoke admin" grant_moderation: "grant moderation" revoke_moderation: "revoke moderation" + backup_operation: "backup operation" screened_emails: title: "Screened Emails" description: "When someone tries to create a new account, the following email addresses will be checked and the registration will be blocked, or some other action performed."