diff options
author | sue445 <sue445@sue445.net> | 2015-03-01 02:07:53 +0900 |
---|---|---|
committer | sue445 <sue445@sue445.net> | 2015-03-01 10:13:01 +0900 |
commit | 51abeaa1bc93862a4d15506a590704f9fc56cfd6 (patch) | |
tree | 745adc2f9567b8cf22c9b2cbe6f399039abb019e /app | |
parent | 7fef8456e8bc92adb0de3f2bc7192e3bedfce47d (diff) | |
download | gitlab-ce-51abeaa1bc93862a4d15506a590704f9fc56cfd6.tar.gz |
Expose avatar_url in projects API
* Impl Project#avatar_url
* Refactor ApplicationHelper: Use Project#avatar_url
* Update changelog
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/application_helper.rb | 6 | ||||
-rw-r--r-- | app/models/project.rb | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 365de3595cd..a81e41819b7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,10 +58,8 @@ module ApplicationHelper Project.find_with_namespace(project_id) end - if project.avatar.present? - image_tag project.avatar.url, options - elsif project.avatar_in_git - image_tag namespace_project_avatar_path(project.namespace, project), options + if project.avatar_url + image_tag project.avatar_url, options else # generated icon project_identicon(project, options) end diff --git a/app/models/project.rb b/app/models/project.rb index d33b25db201..7f2e0b4c17b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -37,6 +37,8 @@ class Project < ActiveRecord::Base include Gitlab::ShellAdapter include Gitlab::VisibilityLevel include Gitlab::ConfigHelper + include Rails.application.routes.url_helpers + extend Gitlab::ConfigHelper extend Enumerize @@ -408,6 +410,14 @@ class Project < ActiveRecord::Base @avatar_file end + def avatar_url + if avatar.present? + [gitlab_config.url, avatar.url].join + elsif avatar_in_git + [gitlab_config.url, namespace_project_avatar_path(namespace, self)].join + end + end + # For compatibility with old code def code path |