diff --git a/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js b/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js index ddf94c61b6e..e47160c7446 100644 --- a/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_logs_staff_action_logs_controller.js @@ -18,7 +18,7 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc self.set('content', result); self.set('loading', false); }); - }.observes('filters.action_name', 'filters.staff_user', 'filters.target_user'), + }.observes('filters.action_name', 'filters.staff_user', 'filters.target_user', 'filters.subject'), toggleFullDetails: function(target) { target.set('showFullDetails', !target.get('showFullDetails')); @@ -26,7 +26,7 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc filtersExists: function() { return (_.size(this.get('filters')) > 0); - }.property('filters.action_name', 'filters.staff_user', 'filters.target_user'), + }.property('filters.action_name', 'filters.staff_user', 'filters.target_user', 'filters.subject'), clearFilter: function(key) { delete this.get('filters')[key]; @@ -55,5 +55,9 @@ Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Disc filterByTargetUser: function(target_user) { this.set('filters.target_user', target_user.username); + }, + + filterBySubject: function(subject) { + this.set('filters.subject', subject); } }); diff --git a/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars b/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars index a034650a8cb..f4c787b026c 100644 --- a/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars +++ b/app/assets/javascripts/admin/templates/logs/staff_action_logs.js.handlebars @@ -20,6 +20,12 @@ {{/if}} + {{#if filters.subject}} + + {{i18n admin.logs.staff_actions.subject}}: {{filters.subject}} + + + {{/if}}
diff --git a/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars b/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars index c7eda988eac..3da2168aa0d 100644 --- a/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars +++ b/app/assets/javascripts/admin/templates/logs/staff_action_logs_list_item.js.handlebars @@ -11,7 +11,7 @@ {{target_user.username}} {{/if}} {{#if subject}} - {{subject}} + {{subject}} {{/if}}
{{unboundAgeWithTooltip created_at}}
diff --git a/app/controllers/admin/staff_action_logs_controller.rb b/app/controllers/admin/staff_action_logs_controller.rb index c31a03d8fea..c6e8bab09fc 100644 --- a/app/controllers/admin/staff_action_logs_controller.rb +++ b/app/controllers/admin/staff_action_logs_controller.rb @@ -1,7 +1,7 @@ class Admin::StaffActionLogsController < Admin::AdminController def index - staff_action_logs = StaffActionLog.with_filters(params.slice(:action_name, :staff_user, :target_user)).limit(200).order('id DESC').includes(:staff_user, :target_user).to_a + staff_action_logs = StaffActionLog.with_filters(params.slice(:action_name, :staff_user, :target_user, :subject)).limit(200).order('id DESC').includes(:staff_user, :target_user).to_a render_serialized(staff_action_logs, StaffActionLogSerializer) end diff --git a/app/models/staff_action_log.rb b/app/models/staff_action_log.rb index 385184fe851..1a9ff9beede 100644 --- a/app/models/staff_action_log.rb +++ b/app/models/staff_action_log.rb @@ -22,6 +22,7 @@ class StaffActionLog < ActiveRecord::Base query = query.where("#{key.to_s}_id = ?", obj_id) end end + query = query.where("subject = ?", filters[:subject]) if filters[:subject] query end end diff --git a/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb b/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb new file mode 100644 index 00000000000..24471d4c03a --- /dev/null +++ b/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb @@ -0,0 +1,5 @@ +class AddSubjectIndexToStaffActionLogs < ActiveRecord::Migration + def change + add_index :staff_action_logs, [:subject, :id] + end +end