Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

120 lines
2.9 KiB
Ruby
Raw Permalink Normal View History

2014-07-22 17:56:14 +02:00
#-- copyright
2020-01-15 11:31:26 +01:00
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
2014-07-22 17:56:14 +02:00
#
# 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:
2021-01-13 17:47:45 +01:00
# Copyright (C) 2006-2013 Jean-Philippe Lang
2014-07-22 17:56:14 +02:00
# 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 COPYRIGHT and LICENSE files for more details.
2014-07-22 17:56:14 +02:00
#++
2015-07-15 16:28:46 +02:00
require "api/decorators/single"
2014-07-22 17:56:14 +02:00
module API
module V3
2015-07-15 16:28:46 +02:00
class RootRepresenter < ::API::Decorators::Single
2017-03-08 13:33:09 +01:00
link :self do
{
href: api_v3_paths.root
}
end
2015-07-15 16:28:46 +02:00
link :configuration do
{
href: api_v3_paths.configuration
}
end
2014-07-22 17:56:14 +02:00
2019-05-29 08:31:57 +02:00
link :memberships do
next unless current_user.allowed_in_any_project?(:view_members) ||
current_user.allowed_in_any_project?(:manage_members)
2015-09-23 10:48:04 +02:00
{
2019-05-29 08:31:57 +02:00
href: api_v3_paths.memberships
}
2015-09-23 10:48:04 +02:00
end
2015-07-15 16:28:46 +02:00
link :priorities do
2014-11-21 10:53:21 +01:00
{
href: api_v3_paths.priorities
}
2014-07-22 17:56:14 +02:00
end
2016-10-18 14:20:43 +01:00
link :relations do
{
href: api_v3_paths.relations
}
end
2015-07-15 16:28:46 +02:00
link :statuses do
2014-07-22 17:56:14 +02:00
{
2015-07-15 16:28:46 +02:00
href: api_v3_paths.statuses
2014-07-22 17:56:14 +02:00
}
end
link :time_entries do
{
href: api_v3_paths.time_entries
}
end
2015-07-15 16:28:46 +02:00
link :types do
2014-11-21 10:53:21 +01:00
{
2015-07-15 16:28:46 +02:00
href: api_v3_paths.types
2014-11-21 10:53:21 +01:00
}
2014-07-22 17:56:14 +02:00
end
2015-07-15 16:28:46 +02:00
2019-05-29 08:31:57 +02:00
link :user do
next unless current_user.logged?
2019-12-12 11:35:14 +01:00
2019-05-29 08:31:57 +02:00
{
href: api_v3_paths.user(current_user.id),
title: current_user.name
}
end
link :userPreferences do
{
2021-06-24 14:03:29 +02:00
href: api_v3_paths.user_preferences(current_user.id)
2019-05-29 08:31:57 +02:00
}
end
2015-08-13 11:29:01 +02:00
link :workPackages do
{
href: api_v3_paths.work_packages
}
end
2015-07-15 16:28:46 +02:00
property :instance_name,
getter: ->(*) { Setting.app_title }
property :core_version,
2019-12-12 11:35:14 +01:00
exec_context: :decorator,
getter: ->(*) { OpenProject::VERSION.to_semver },
if: ->(*) { current_user.admin? }
2017-03-08 13:33:09 +01:00
def _type
"Root"
end
2014-07-22 17:56:14 +02:00
end
end
end