From 51856df0d1fa913474bf1447ade4c315687f7ff9 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 22 Feb 2013 20:43:51 +0600 Subject: [PATCH] #946 make avatar url --- app/models/activity_feed_observer.rb | 14 +++++++------- .../partials/_git_new_push_notification.haml | 7 +++---- .../partials/_new_comment_commit_notification.haml | 6 +++--- .../partials/_new_comment_notification.haml | 6 +++--- .../partials/_new_issue_notification.haml | 6 +++--- .../partials/_wiki_new_commit_notification.haml | 6 +++--- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index fb9a3f6e5..80b497721 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -18,7 +18,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => recipient, :kind => 'new_issue_notification', - :data => {:user_name => record.user.name, :user_email => record.user.email, :user_uname => record.user.uname,:issue_serial_id => record.serial_id, + :data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id,:issue_serial_id => record.serial_id, :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name, :project_owner => record.project.owner.uname} ) end @@ -28,7 +28,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => record.user, :kind => 'issue_assign_notification', - :data => {:user_name => record.user.name, :user_email => record.user.email, :issue_serial_id => record.serial_id, + :data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :issue_serial_id => record.serial_id, :project_id => record.project.id, :issue_title => record.title, :project_name => record.project.name, :project_owner => record.project.owner.uname} ) end @@ -42,7 +42,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_notification', - :data => {:user_name => record.user.name, :user_email => record.user.email, :user_uname => record.user.uname, :comment_body => record.body, + :data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :comment_body => record.body, :issue_title => record.commentable.title, :issue_serial_id => record.commentable.serial_id, :project_id => record.commentable.project.id, :comment_id => record.id, :project_name => record.project.name, :project_owner => record.project.owner.uname} ) @@ -61,7 +61,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create( :user => subscribe.user, :kind => 'new_comment_commit_notification', - :data => {:user_name => record.user.name, :user_email => record.user.email, :user_uname => record.user.uname, :comment_body => record.body, + :data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :comment_body => record.body, :commit_message => record.commentable.message, :commit_id => record.commentable.id, :project_id => record.project.id, :comment_id => record.id, :project_name => record.project.name, :project_owner => record.project.owner.uname} ) @@ -90,7 +90,7 @@ class ActivityFeedObserver < ActiveRecord::Observer options = {:project_id => record.project.id, :project_name => record.project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type, :user_email => record.project.repo.log(branch_name, nil).first.author.email, :project_owner => record.project.owner.uname} - options.merge!({:user_name => first_commiter.name, :user_uname => first_commiter.uname}) if first_commiter + options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name}) if first_commiter end record.project.admins.each do |recipient| @@ -109,7 +109,7 @@ class ActivityFeedObserver < ActiveRecord::Observer ActivityFeed.create!( :user => recipient, :kind => 'wiki_new_commit_notification', - :data => {:user_name => actor.name, :user_email => actor.email, :project_id => project.id, :user_uname => actor.uname, + :data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id, :project_name => project.name, :commit_sha => record[:commit_sha], :project_owner => project.owner.uname} ) end @@ -144,7 +144,7 @@ class ActivityFeedObserver < ActiveRecord::Observer :kind => 'build_list_notification', :data => {:task_num => record.bs_id, :build_list_id => record.id, :status => record.status, :updated_at => record.updated_at, :project_id => record.project_id, :project_name => record.project.name, :project_owner => record.project.owner.uname, - :user_name => record.user.name, :user_email => record.user.email, :user_uname => record.user.uname} + :user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id} ) end end diff --git a/app/views/activity_feeds/partials/_git_new_push_notification.haml b/app/views/activity_feeds/partials/_git_new_push_notification.haml index 4ac90c45c..c569ad932 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -1,10 +1,9 @@ +-user= User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email) .top - - if defined?(user_email) - .image - = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') + .image= link_to(image_tag(avatar_url(user, :small), :alt => 'avatar'), user_path(user)) if user.persisted? .text %span - -user_link = defined?(user_name) ? (defined?(user_uname) ? link_to(user_name, user_path(user_uname)) : user_name) : user_email + -user_link = defined?(user_email) ? (user ? link_to(user_name, user_path(user)) : user_name) : user_email = raw t("notifications.bodies.#{change_type}_branch", {:branch_name => branch_name, :user_link => user_link}) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both diff --git a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml index 7bc66684a..3c3abd5c1 100644 --- a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml @@ -1,9 +1,9 @@ +-user= User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email) .top - .image - = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') + .image= link_to(image_tag(avatar_url(user, :small), :alt => 'avatar'), user_path(user)) if user.persisted? .text %span - = raw t("notifications.bodies.new_comment_notification.title", :user_link => defined?(user_uname) ? link_to(user_name, user_path(user_uname)) : user_name ) + = raw t("notifications.bodies.new_comment_notification.title", :user_link => user.persisted? ? link_to(user_name, user_path(user)) : user_name ) = raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_owner, project_name, commit_id) + "#comment#{comment_id}")}) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both diff --git a/app/views/activity_feeds/partials/_new_comment_notification.haml b/app/views/activity_feeds/partials/_new_comment_notification.haml index c4c27ac83..62db77611 100644 --- a/app/views/activity_feeds/partials/_new_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -1,9 +1,9 @@ +-user= User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email) .top - .image - = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') + .image= link_to(image_tag(avatar_url(user, :small), :alt => 'avatar'), user_path(user)) if user.persisted? .text %span - = raw t("notifications.bodies.new_comment_notification.title", {:user_link => defined?(user_uname) ? link_to(user_name, user_path(user_uname)) : user_name}) + = raw t("notifications.bodies.new_comment_notification.title", {:user_link => user.persisted? ? link_to(user_name, user_path(user)) : user_name}) = raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_owner, project_name, issue_serial_id) + "#comment#{comment_id}")}) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both diff --git a/app/views/activity_feeds/partials/_new_issue_notification.haml b/app/views/activity_feeds/partials/_new_issue_notification.haml index 9013c0861..c653aba16 100644 --- a/app/views/activity_feeds/partials/_new_issue_notification.haml +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -1,9 +1,9 @@ +-user= User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email) .top - .image - = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') + .image= link_to(image_tag(avatar_url(user, :small), :alt => 'avatar'), user_path(user)) if user.persisted? .text %span - = raw t("notifications.bodies.new_issue_notification", { :user_link => defined?(user_uname) ? link_to(user_name, user_path(user_uname)) : user_name, :issue_link => project_issue_path(project_owner, project_name, issue_serial_id)}) + = raw t("notifications.bodies.new_issue_notification", { :user_link => user.persisted? ? link_to(user_name, user_path(user)) : user_name, :issue_link => project_issue_path(project_owner, project_name, issue_serial_id)}) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index 12078c77d..7a24f2131 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -1,9 +1,9 @@ +-user= User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email) .top - .image - = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') + .image= link_to(image_tag(avatar_url(user, :small), :alt => 'avatar'), user_path(user)) if user.persisted? .text %span - -user_link = defined?(user_uname) ? link_to(user_name, user_path(user_uname)) : user_name + -user_link = user.persisted? ? link_to(user_name, user_path(user)) : user_name = raw t("notifications.bodies.wiki_new_commit_notification", {:user_link => user_link, :history_link => link_to("wiki", history_project_wiki_index_path(project_owner, project_name))}) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both