diff options
author | Robert Speicher <robert@gitlab.com> | 2015-07-30 21:38:48 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2015-07-30 21:38:48 +0000 |
commit | a876db48d95588837895e83e92d0cf3f8a129d02 (patch) | |
tree | ea6121571eed7bae7b6a8b96d0e2f605d90d6f8e /app/models | |
parent | 6d6f807b759d13d111202129d8be2c88d7be819f (diff) | |
parent | 2a60b8006b1374aec998370f9cfe5b574255712f (diff) | |
download | gitlab-ce-a876db48d95588837895e83e92d0cf3f8a129d02.tar.gz |
Merge branch 'api-new-attributes' into 'master'
Add project star and fork count, group avatar URL and user/group web URL attributes to API
Addresses internal https://dev.gitlab.org/gitlab/gitlabhq/issues/2521.
See merge request !1058
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/group.rb | 6 | ||||
-rw-r--r-- | app/models/project.rb | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/app/models/group.rb b/app/models/group.rb index 051c672cb33..cfb8faa1491 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -56,6 +56,12 @@ class Group < Namespace name end + def avatar_url(size = nil) + if avatar.present? + [gitlab_config.url, avatar.url].join + end + end + def owners @owners ||= group_members.owners.map(&:user) end diff --git a/app/models/project.rb b/app/models/project.rb index 1800c3a7e01..0921fdfe9b4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -36,7 +36,6 @@ class Project < ActiveRecord::Base include Gitlab::ConfigHelper include Gitlab::ShellAdapter include Gitlab::VisibilityLevel - include Rails.application.routes.url_helpers include Referable include Sortable @@ -316,7 +315,7 @@ class Project < ActiveRecord::Base end def web_url - [gitlab_config.url, path_with_namespace].join('/') + Rails.application.routes.url_helpers.namespace_project_url(self.namespace, self) end def web_url_without_protocol @@ -433,7 +432,7 @@ class Project < ActiveRecord::Base if avatar.present? [gitlab_config.url, avatar.url].join elsif avatar_in_git - [gitlab_config.url, namespace_project_avatar_path(namespace, self)].join + Rails.application.routes.url_helpers.namespace_project_avatar_url(namespace, self) end end @@ -571,7 +570,7 @@ class Project < ActiveRecord::Base end def http_url_to_repo - [gitlab_config.url, '/', path_with_namespace, '.git'].join('') + "#{web_url}.git" end # Check if current branch name is marked as protected in the system |