diff options
author | Rémy Coutable <remy@rymai.me> | 2018-10-01 12:38:25 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-02 19:04:48 +0300 |
commit | 615f1272cd3270e067ef18b8db27c28b6f42b64f (patch) | |
tree | a385cf3f5cde7fe7f487e48dd8935185ad9c5b73 /app | |
parent | 314488aed71653364e3f895093c2e1087c61f1ee (diff) |
Merge branch 'sh-fix-forks-with-no-gravatar' into 'master'
Fix Error 500 when forking projects with Gravatar disabled
Closes #50254
See merge request gitlab-org/gitlab-ce!21985
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/avatars_helper.rb | 21 | ||||
-rw-r--r-- | app/views/projects/edit.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/forks/_fork_button.html.haml | 4 |
3 files changed, 11 insertions, 16 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 494f785e305..4b087f924ab 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -1,10 +1,10 @@ module AvatarsHelper - def project_icon(project_id, options = {}) - source_icon(Project, project_id, options) + def project_icon(project, options = {}) + source_icon(project, options) end - def group_icon(group_id, options = {}) - source_icon(Group, group_id, options) + def group_icon(group, options = {}) + source_icon(group, options) end # Takes both user and email and returns the avatar_icon by @@ -108,16 +108,11 @@ module AvatarsHelper private - def source_icon(klass, source_id, options = {}) - source = - if source_id.respond_to?(:avatar_url) - source_id - else - klass.find_by_full_path(source_id) - end + def source_icon(source, options = {}) + avatar_url = source.try(:avatar_url) - if source.avatar_url - image_tag source.avatar_url, options + if avatar_url + image_tag avatar_url, options else source_identicon(source, options) end diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index acdde9e0f70..c3711784cc5 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -47,7 +47,7 @@ .form-group - if @project.avatar? .avatar-container.s160.append-bottom-15 - = project_icon(@project.full_path, alt: '', class: 'avatar project-avatar s160', width: 160, height: 160) + = project_icon(@project, alt: '', class: 'avatar project-avatar s160', width: 160, height: 160) - if @project.avatar_in_git %p.light = _("Project avatar in repository: %{link}").html_safe % { link: @project.avatar_in_git } diff --git a/app/views/projects/forks/_fork_button.html.haml b/app/views/projects/forks/_fork_button.html.haml index 12cf40bb65f..a69146513d8 100644 --- a/app/views/projects/forks/_fork_button.html.haml +++ b/app/views/projects/forks/_fork_button.html.haml @@ -5,7 +5,7 @@ .bordered-box.fork-thumbnail.text-center.prepend-left-default.append-right-default.prepend-top-default.append-bottom-default.forked = link_to project_path(forked_project) do - if /no_((\w*)_)*avatar/.match(avatar) - = project_icon(namespace, class: "avatar s100 identicon") + = group_icon(namespace, class: "avatar s100 identicon") - else .avatar-container.s100 = image_tag(avatar, class: "avatar s100") @@ -18,7 +18,7 @@ class: ("disabled has-tooltip" unless can_create_project), title: (_('You have reached your project limit') unless can_create_project) do - if /no_((\w*)_)*avatar/.match(avatar) - = project_icon(namespace, class: "avatar s100 identicon") + = group_icon(namespace, class: "avatar s100 identicon") - else .avatar-container.s100 = image_tag(avatar, class: "avatar s100") |