From 19ffd77d32b0457aad4f1ad4577f8c9f5fb31a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Fri, 26 May 2017 18:09:29 +0200 Subject: [PATCH 1/2] Requests failed if smart annotation referenced a user who was no longer in the team. [fixes SCI-1305] --- app/helpers/application_helper.rb | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a59b5e729..95e991dff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -184,6 +184,7 @@ module ApplicationHelper new_text = text.gsub(sa_user) do |el| match = el.match(sa_user) user = User.find_by_id(match[2].base62_decode) + next unless user team ||= current_team popover_for_user_name(user, team) end @@ -192,13 +193,8 @@ module ApplicationHelper # Generate smart annotation link for one user object def popover_for_user_name(user, team = nil) - if user && - team && - UserTeam.user_in_team(user, team).any? - user_t = user.user_teams - .where('user_teams.team_id = ?', team) - .first - end + user_still_in_team = user.teams.include?(team) + user_description = %(
thumb
@@ -207,9 +203,12 @@ module ApplicationHelper

#{user.email}

) - if team.present? + if user_still_in_team + user_t = user.user_teams + .where('user_teams.team_id = ?', team) + .first user_description += %(

- #{I18n.t('atwho.popover_html', + #{I18n.t('atwho.users.popover_html', role: user_t.role.capitalize, team: user_t.team.name, time: user_t.created_at.strftime('%B %Y'))} @@ -218,13 +217,16 @@ module ApplicationHelper user_description += %(

) end + user_name = user.full_name + user_name << ' ' + I18n.t('atwho.res.removed') if !user_still_in_team + raw("") + - raw('') + user.full_name + raw('') + "alt='avatar' class='atwho-user-img-popover'>") + + raw('') + user_name + raw('') end def user_avatar_absolute_url(user, style) From e8f842c29faf739c5bc61f18a27af00347f2501c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Mon, 29 May 2017 11:39:17 +0200 Subject: [PATCH 2/2] Forgot to add the updated locales. [fixes SCI-1305] --- config/locales/en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index c792e8955..b2f1e77b4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1575,10 +1575,11 @@ en: confirm_2: "to confirm" dismiss_1: "esc" dismiss_2: "to dismiss" + popover_html: "Team: %{team}
Role: %{role}
Joined: %{time}" res: archived: "(archived)" + removed: "(removed)" deleted: "(deleted)" - popover_html: "Team: %{team}
Role: %{role}
Joined: %{time}" zip_export: notification_title: 'Your package is ready to be exported!'