summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-03-01 10:54:42 +0100
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-03-01 10:54:42 +0100
commit93bacb03e5ea33a67bcc8198862a23d2038bf6ef (patch)
tree40eeda3d6162a1a833f2e1b9c95fcd92d566bff6 /app
parent7486bc0ae33adc141abbca2ea5dea833e56d5409 (diff)
parent51abeaa1bc93862a4d15506a590704f9fc56cfd6 (diff)
downloadgitlab-ce-93bacb03e5ea33a67bcc8198862a23d2038bf6ef.tar.gz
Merge pull request #8890 from sue445/feature/project_api_avatar_url
Expose avatar_url in projects API
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb6
-rw-r--r--app/models/project.rb10
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