From 97a4d8aea46fb45894f6e47597320ed2f6a12495 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 4 Feb 2014 14:46:15 +0200 Subject: Improve code according to new gitlab_git Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 4f636fc54a3..8f54d0d4d84 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -79,7 +79,16 @@ module API end class RepoObject < Grape::Entity - expose :name, :commit + expose :name + + expose :commit do |repo_obj, options| + if repo_obj.respond_to?(:commit) + repo_obj.commit + elsif options[:project] + options[:project].repository.commit(repo_obj.target) + end + end + expose :protected do |repo, options| if options[:project] options[:project].protected_branch? repo.name @@ -87,6 +96,16 @@ module API end end + class RepoTreeObject < Grape::Entity + expose :id, :name, :type + + expose :mode do |obj, options| + filemode = obj.mode.to_s(8) + filemode = "0" + filemode if filemode.length < 6 + filemode + end + end + class RepoCommit < Grape::Entity expose :id, :short_id, :title, :author_name, :author_email, :created_at end -- cgit v1.2.1 From 1d48904ac807c6d382c8965329085b321381cc3d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 13 Feb 2014 15:45:24 +0200 Subject: Show avatars in ajax user selectbox Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 8f54d0d4d84..8557fa074d4 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -6,6 +6,12 @@ module API expose :is_admin?, as: :is_admin expose :can_create_group?, as: :can_create_group expose :can_create_project?, as: :can_create_project + + expose :avatar_url do |user, options| + if user.avatar.present? + user.avatar.url + end + end end class UserSafe < Grape::Entity -- cgit v1.2.1