exclude non active principals from result set

pull/5234/head
Jens Ulferts 8 years ago
parent c9e1a85421
commit 365143ded3
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 1
      app/models/queries/principals.rb
  2. 44
      app/models/queries/principals/filters/status_filter.rb
  3. 2
      lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer.rb
  4. 3
      lib/api/v3/queries/schemas/user_filter_dependency_representer.rb
  5. 12
      spec/lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer_spec.rb
  6. 4
      spec/lib/api/v3/queries/schemas/user_filter_dependency_representer_spec.rb

@ -34,4 +34,5 @@ module Queries::Principals
register.filter query, filters::TypeFilter
register.filter query, filters::MemberFilter
register.filter query, filters::StatusFilter
end

@ -0,0 +1,44 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class Queries::Principals::Filters::StatusFilter < Queries::Principals::Filters::PrincipalFilter
def allowed_values
::Principal::STATUSES.map do |key, value|
[key, value]
end
end
def type
:list
end
def self.key
:status
end
end

@ -37,7 +37,7 @@ module API
private
def filter_query
params = []
params = [{ status: { operator: '=', values: [Principal::STATUSES[:active].to_s] } }]
unless Setting.work_package_group_assignment?
params << { type: { operator: '=', values: ['User'] } }

@ -37,7 +37,8 @@ module API
private
def filter_query
params = [{ type: { operator: '=', values: ['User'] } }]
params = [{ type: { operator: '=', values: ['User'] } },
{ status: { operator: '=', values: [Principal::STATUSES[:active].to_s] } }]
if filter.context
params << { member: { operator: '=', values: [filter.context.id.to_s] } }

@ -73,7 +73,8 @@ describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter do
context 'within a project with group assignment' do
let(:filter_query) do
[{ member: { operator: '=', values: [project.id.to_s] } }]
[{ status: { operator: '=', values: ['1'] } },
{ member: { operator: '=', values: [project.id.to_s] } }]
end
let(:group_assignment_enabled) { true }
@ -92,7 +93,8 @@ describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter do
context 'within a project without group assignment' do
let(:filter_query) do
[{ type: { operator: '=', values: ['User'] } },
[{ status: { operator: '=', values: ['1'] } },
{ type: { operator: '=', values: ['User'] } },
{ member: { operator: '=', values: [project.id.to_s] } }]
end
@ -112,7 +114,8 @@ describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter do
context 'global with no group assignments' do
let(:project) { nil }
let(:filter_query) do
[{ type: { operator: '=', values: ['User'] } },
[{ status: { operator: '=', values: ['1'] } },
{ type: { operator: '=', values: ['User'] } },
{ member: { operator: '*', values: [] } }]
end
@ -132,7 +135,8 @@ describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter do
context 'global with group assignments' do
let(:project) { nil }
let(:filter_query) do
[{ member: { operator: '*', values: [] } }]
[{ status: { operator: '=', values: ['1'] } },
{ member: { operator: '*', values: [] } }]
end
let(:group_assignment_enabled) { true }

@ -50,6 +50,7 @@ describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter do
let(:type) { '[]User' }
let(:filter_query) do
[{ type: { operator: '=', values: ['User'] } },
{ status: { operator: '=', values: ['1'] } },
{ member: { operator: '=', values: [project.id.to_s] } }]
end
let(:href) do
@ -71,7 +72,8 @@ describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter do
context 'global' do
let(:project) { nil }
let(:filter_query) do
[{ type: { operator: '=', values: ['User'] } }]
[{ type: { operator: '=', values: ['User'] } },
{ status: { operator: '=', values: ['1'] } }]
end
context "for operator '='" do

Loading…
Cancel
Save