FIX: export user list based on trust level filter

This commit is contained in:
Arpit Jalan 2016-03-07 18:47:10 +05:30
parent 607901cf9d
commit 05288144b5
3 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,7 @@ export default Discourse.Route.extend({
actions: {
exportUsers() {
exportEntity('user_list').then(outputExportResult);
exportEntity('user_list', {trust_level: this.controllerFor('admin-users-list-show').get('query')}).then(outputExportResult);
},
sendInvites() {

View File

@ -30,7 +30,7 @@ class ExportCsvController < ApplicationController
@_export_params ||= begin
params.require(:entity)
params.require(:entity_type)
params.permit(:entity, :entity_type, args: [:name, :start_date, :end_date, :category_id, :group_id])
params.permit(:entity, :entity_type, args: [:name, :start_date, :end_date, :category_id, :group_id, :trust_level])
end
end
end

View File

@ -53,10 +53,14 @@ module Jobs
def user_list_export
user_array = []
user_field_ids = UserField.pluck(:id)
condition = {}
if @extra && @extra[:trust_level] && trust_level = TrustLevel.levels[@extra[:trust_level].to_sym]
condition = {trust_level: trust_level}
end
if SiteSetting.enable_sso
# SSO enabled
User.includes(:user_stat, :single_sign_on_record, :groups).find_each do |user|
User.where(condition).includes(:user_stat, :single_sign_on_record, :groups).find_each do |user|
user_info_string = get_base_user_string(user)
user_info_string = add_single_sign_on(user, user_info_string)
user_info_string = add_custom_fields(user, user_info_string, user_field_ids)
@ -66,7 +70,7 @@ module Jobs
end
else
# SSO disabled
User.includes(:user_stat, :groups).find_each do |user|
User.where(condition).includes(:user_stat, :groups).find_each do |user|
user_info_string = get_base_user_string(user)
user_info_string = add_custom_fields(user, user_info_string, user_field_ids)
user_info_string = add_group_names(user, user_info_string)