Merge pull request #2239 from opf/feature/16972_add_assignee_responsible_to_wp_form
16972 add assignee responsible to wp formpull/2092/merge
commit
6ead8dddcb
@ -0,0 +1,48 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2014 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-2013 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. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Projects |
||||
class AvailableAssigneesAPI < Grape::API |
||||
resource :available_assignees do |
||||
get do |
||||
authorize(:view_project, context: @project) |
||||
|
||||
available_assignees = @project.possible_assignees |
||||
total = available_assignees.count |
||||
self_link = api_v3_paths.available_assignees(@project.id) |
||||
::API::V3::Users::UserCollectionRepresenter.new(available_assignees, |
||||
total, |
||||
self_link) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,48 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2014 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-2013 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. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Projects |
||||
class AvailableResponsiblesAPI < Grape::API |
||||
resource :available_responsibles do |
||||
get do |
||||
authorize(:view_project, context: @project) |
||||
|
||||
available_responsibles = @project.possible_responsibles |
||||
total = available_responsibles.count |
||||
self_link = api_v3_paths.available_responsibles(@project.id) |
||||
::API::V3::Users::UserCollectionRepresenter.new(available_responsibles, |
||||
total, |
||||
self_link) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,162 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2014 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-2013 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. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Utilities |
||||
module PathHelper |
||||
include API::Utilities::UrlHelper |
||||
|
||||
class ApiV3Path |
||||
def self.root |
||||
"#{root_path}api/v3" |
||||
end |
||||
|
||||
def self.activity(id) |
||||
"#{root}/activities/#{id}" |
||||
end |
||||
|
||||
def self.attachment(id) |
||||
"#{root}/attachments/#{id}" |
||||
end |
||||
|
||||
def self.available_assignees(project_id) |
||||
"#{project(project_id)}/available_assignees" |
||||
end |
||||
|
||||
def self.available_responsibles(project_id) |
||||
"#{project(project_id)}/available_responsibles" |
||||
end |
||||
|
||||
def self.available_watchers(work_package_id) |
||||
"#{work_package(work_package_id)}/watchers" |
||||
end |
||||
|
||||
def self.categories(project_id) |
||||
"#{project(project_id)}/categories" |
||||
end |
||||
|
||||
def self.preview_textile(link) |
||||
preview_markup(:textile, link) |
||||
end |
||||
|
||||
def self.priorities |
||||
"#{root}/priorities" |
||||
end |
||||
|
||||
def self.projects |
||||
"#{root}/projects" |
||||
end |
||||
|
||||
def self.project(id) |
||||
"#{projects}/#{id}" |
||||
end |
||||
|
||||
def self.query(id) |
||||
"#{root}/queries/#{id}" |
||||
end |
||||
|
||||
def self.relation(id) |
||||
"#{root}/relations/#{id}" |
||||
end |
||||
|
||||
def self.statuses |
||||
"#{root}/statuses" |
||||
end |
||||
|
||||
def self.status(id) |
||||
"#{statuses}/#{id}" |
||||
end |
||||
|
||||
def self.users |
||||
"#{root}/users" |
||||
end |
||||
|
||||
def self.user(id) |
||||
"#{users}/#{id}" |
||||
end |
||||
|
||||
def self.versions(project_id) |
||||
"#{project(project_id)}/versions" |
||||
end |
||||
|
||||
def self.watcher(id, work_package_id) |
||||
"#{work_package(work_package_id)}/watchers/#{id}" |
||||
end |
||||
|
||||
def self.work_packages |
||||
"#{root}/work_packages" |
||||
end |
||||
|
||||
def self.work_package(id) |
||||
"#{work_packages}/#{id}" |
||||
end |
||||
|
||||
def self.work_package_activities(id) |
||||
"#{work_package(id)}/activities" |
||||
end |
||||
|
||||
def self.work_package_relations(id) |
||||
"#{work_package(id)}/relations" |
||||
end |
||||
|
||||
def self.work_package_relation(id, work_package_id) |
||||
"#{work_package_relations(work_package_id)}/#{id}" |
||||
end |
||||
|
||||
def self.work_package_form(id) |
||||
"#{work_package(id)}/form" |
||||
end |
||||
|
||||
def self.work_package_watchers(id) |
||||
"#{work_package(id)}/watchers" |
||||
end |
||||
|
||||
def self.root_path |
||||
@@root_path ||= Class.new.tap do |c| |
||||
c.extend(::API::V3::Utilities::PathHelper) |
||||
end.root_path |
||||
end |
||||
|
||||
def self.preview_markup(method, link) |
||||
path = "#{root}/render/#{method}" |
||||
|
||||
path += "?#{link}" unless link.nil? |
||||
|
||||
path |
||||
end |
||||
end |
||||
|
||||
def api_v3_paths |
||||
ApiV3Path |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,255 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2014 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-2013 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. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe ::API::V3::Utilities::PathHelper do |
||||
let(:helper) { Class.new.tap { |c| c.extend(::API::V3::Utilities::PathHelper) }.api_v3_paths } |
||||
|
||||
shared_examples_for 'api v3 path' do |
||||
it { is_expected.to match(/^\/api\/v3/) } |
||||
end |
||||
|
||||
describe '#root' do |
||||
subject { helper.root } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
end |
||||
|
||||
describe '#activity' do |
||||
subject { helper.activity 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/activities\/1/) } |
||||
end |
||||
|
||||
describe '#attachment' do |
||||
subject { helper.attachment 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/attachments\/1/) } |
||||
end |
||||
|
||||
describe '#available_assignees' do |
||||
subject { helper.available_assignees 42 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/projects\/42\/available_assignees/) } |
||||
end |
||||
|
||||
describe '#available_responsibles' do |
||||
subject { helper.available_responsibles 42 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/projects\/42\/available_responsibles/) } |
||||
end |
||||
|
||||
describe '#available_watchers' do |
||||
subject { helper.available_watchers 42 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/watchers/) } |
||||
end |
||||
|
||||
describe '#categories' do |
||||
subject { helper.categories 42 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/projects\/42\/categories/) } |
||||
end |
||||
|
||||
describe '#preview_textile' do |
||||
subject { helper.preview_textile '/api/v3/work_packages/42' } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/render\/textile/) } |
||||
|
||||
it { is_expected.to match(/\?\/api\/v3\/work_packages\/42$/) } |
||||
end |
||||
|
||||
describe '#priorities' do |
||||
subject { helper.priorities } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/priorities/) } |
||||
end |
||||
|
||||
describe 'projects paths' do |
||||
describe '#projects' do |
||||
subject { helper.projects } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/projects/) } |
||||
end |
||||
|
||||
describe '#project' do |
||||
subject { helper.project 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/projects\/1/) } |
||||
end |
||||
end |
||||
|
||||
describe '#query' do |
||||
subject { helper.query 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/queries\/1/) } |
||||
end |
||||
|
||||
describe 'relations paths' do |
||||
describe '#relation' do |
||||
subject { helper.relation 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/relations/) } |
||||
end |
||||
|
||||
describe '#relation' do |
||||
subject { helper.relation 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/relations\/1/) } |
||||
end |
||||
end |
||||
|
||||
describe 'statuses paths' do |
||||
describe '#statuses' do |
||||
subject { helper.statuses } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/statuses/) } |
||||
end |
||||
|
||||
describe '#status' do |
||||
subject { helper.status 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/statuses\/1/) } |
||||
end |
||||
end |
||||
|
||||
describe '#user' do |
||||
subject { helper.user 1 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/users\/1/) } |
||||
end |
||||
|
||||
describe '#versions' do |
||||
subject { helper.versions 42 } |
||||
|
||||
it_behaves_like 'api v3 path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/projects\/42\/versions/) } |
||||
end |
||||
|
||||
describe 'work packages paths' do |
||||
shared_examples_for 'api v3 work packages path' do |
||||
it { is_expected.to match(/^\/api\/v3\/work_packages/) } |
||||
end |
||||
|
||||
describe '#work_packages' do |
||||
subject { helper.work_packages } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
end |
||||
|
||||
describe '#work_package' do |
||||
subject { helper.work_package 1 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/1/) } |
||||
end |
||||
|
||||
describe '#work_package_activities' do |
||||
subject { helper.work_package_activities 42 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/activities/) } |
||||
end |
||||
|
||||
describe '#work_package_relations' do |
||||
subject { helper.work_package_relations 42 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/relations/) } |
||||
end |
||||
|
||||
describe '#work_package_relation' do |
||||
subject { helper.work_package_relation 1, 42 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/relations\/1/) } |
||||
end |
||||
|
||||
describe '#work_package_form' do |
||||
subject { helper.work_package_form 1 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/1\/form/) } |
||||
end |
||||
|
||||
describe '#work_package_watchers' do |
||||
subject { helper.work_package_watchers 1 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/1\/watchers/) } |
||||
end |
||||
|
||||
describe '#watcher' do |
||||
subject { helper.watcher 1, 42 } |
||||
|
||||
it_behaves_like 'api v3 work packages path' |
||||
|
||||
it { is_expected.to match(/^\/api\/v3\/work_packages\/42\/watchers\/1/) } |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue