Commit a784b996 authored by Douwe Maan's avatar Douwe Maan

Add project star and fork count, group avatar URL and user/group web URL attributes to API

parent 43d11880
......@@ -16,6 +16,7 @@ v 7.14.0 (unreleased)
- Expire Rails cache entries after two weeks to prevent endless Redis growth
- Add support for destroying project milestones (Stan Hu)
- Add fetch command to the MR page
- Add project star and fork count, group avatar URL and user/group web URL attributes to API
v 7.13.1
- Fix: Label modifications are not reflected in existing notes and in the issue list
......
......@@ -17,6 +17,7 @@ require 'carrierwave/orm/activerecord'
require 'file_size_validator'
class Group < Namespace
include Gitlab::ConfigHelper
include Referable
has_many :group_members, dependent: :destroy, as: :source, class_name: 'GroupMember'
......@@ -56,6 +57,16 @@ class Group < Namespace
name
end
def avatar_url(size = nil)
if avatar.present?
[gitlab_config.url, avatar.url].join
end
end
def web_url
[gitlab_config.url, "groups", self.path].join('/')
end
def owners
@owners ||= group_members.owners.map(&:user)
end
......
......@@ -637,6 +637,10 @@ class User < ActiveRecord::Base
end
end
def web_url
[gitlab_config.url, "u", self.username].join('/')
end
def all_emails
[self.email, *self.emails.map(&:email)]
end
......
......@@ -5,7 +5,7 @@ module API
end
class UserBasic < UserSafe
expose :id, :state, :avatar_url
expose :id, :state, :avatar_url, :web_url
end
class User < UserBasic
......@@ -59,6 +59,7 @@ module API
expose :namespace
expose :forked_from_project, using: Entities::ForkedFromProject, if: lambda{ | project, options | project.forked? }
expose :avatar_url
expose :star_count, :forks_count
end
class ProjectMember < UserBasic
......@@ -69,6 +70,7 @@ module API
class Group < Grape::Entity
expose :id, :name, :path, :description
expose :avatar_url, :web_url
end
class GroupDetail < Group
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment