[refs #265] changed feed messages

This commit is contained in:
Alexander Machehin 2012-03-14 23:00:26 +06:00
parent f11fc179d3
commit 3642163fd7
12 changed files with 56 additions and 43 deletions

View File

@ -15,8 +15,8 @@ class CommentsController < ApplicationController
@comment = @commentable.comments.build(params[:comment]) if @commentable.class == Issue @comment = @commentable.comments.build(params[:comment]) if @commentable.class == Issue
if @commentable.class == Grit::Commit if @commentable.class == Grit::Commit
@comment = Comment.new(params[:comment].merge(:commentable_id => @commentable.id.hex, :commentable_type => @commentable.class.name)) @comment = Comment.new(params[:comment].merge(:commentable_id => @commentable.id.hex, :commentable_type => @commentable.class.name))
@comment.project = @project
end end
@comment.project = @project
@comment.user_id = current_user.id @comment.user_id = current_user.id
if @comment.save if @comment.save
flash[:notice] = I18n.t("flash.comment.saved") flash[:notice] = I18n.t("flash.comment.saved")

View File

@ -19,7 +19,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
:user => recipient, :user => recipient,
:kind => 'new_issue_notification', :kind => 'new_issue_notification',
:data => {:user_name => record.creator.name, :user_email => record.creator.email, :user_id => record.creator_id,:issue_serial_id => record.serial_id, :data => {:user_name => record.creator.name, :user_email => record.creator.email, :user_id => record.creator_id,:issue_serial_id => record.serial_id,
:issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name} :issue_title => record.title, :project_id => record.project.id, :project_name => record.project.name, :project_owner => record.project.owner.uname}
) )
end end
@ -29,7 +29,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
:user => record.user, :user => record.user,
:kind => 'issue_assign_notification', :kind => 'issue_assign_notification',
:data => {:user_name => record.creator.name, :user_email => record.creator.email, :user_id => record.creator_id, :issue_serial_id => record.serial_id, :data => {:user_name => record.creator.name, :user_email => record.creator.email, :user_id => record.creator_id, :issue_serial_id => record.serial_id,
:project_id => record.project.id, :issue_title => record.title, :project_name => record.project.name} :project_id => record.project.id, :issue_title => record.title, :project_name => record.project.name, :project_owner => record.project.owner.uname}
) )
end end
@ -44,7 +44,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
:kind => 'new_comment_notification', :kind => 'new_comment_notification',
:data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :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, :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} :comment_id => record.id, :project_name => record.project.name, :project_owner => record.project.owner.uname}
) )
end end
end end
@ -63,7 +63,7 @@ class ActivityFeedObserver < ActiveRecord::Observer
:kind => 'new_comment_commit_notification', :kind => 'new_comment_commit_notification',
:data => {:user_name => record.user.name, :user_email => record.user.email, :user_id => record.user_id, :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.encode_to_default, :commit_id => record.commentable.id, :commit_message => record.commentable.message.encode_to_default, :commit_id => record.commentable.id,
:project_id => record.project.id, :comment_id => record.id, :project_name => record.project.name} :project_id => record.project.id, :comment_id => record.id, :project_name => record.project.name, :project_owner => record.project.owner.uname}
) )
end end
end end
@ -80,11 +80,13 @@ class ActivityFeedObserver < ActiveRecord::Observer
if change_type == 'delete' if change_type == 'delete'
kind = 'git_delete_branch_notification' kind = 'git_delete_branch_notification'
options = {:project_id => record.project.id, :project_name => record.project.name, :branch_name => branch_name, :change_type => change_type} options = {:project_id => record.project.id, :project_name => record.project.name, :branch_name => branch_name,
:change_type => change_type, :project_owner => record.project.owner.uname}
else else
kind = 'git_new_push_notification' kind = 'git_new_push_notification'
options = {:project_id => record.project.id, :project_name => record.project.name, :last_commits => last_commits, :branch_name => branch_name, 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.git_repository.repo.log(branch_name, nil).first.author.email} :change_type => change_type, :user_email => record.project.git_repository.repo.log(branch_name, nil).first.author.email,
:project_owner => record.project.owner.uname}
options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name}) if first_commiter options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name}) if first_commiter
end end
@ -107,7 +109,8 @@ class ActivityFeedObserver < ActiveRecord::Observer
ActivityFeed.create( ActivityFeed.create(
:user => User.find(recipient),#record.user, :user => User.find(recipient),#record.user,
:kind => 'wiki_new_commit_notification', :kind => 'wiki_new_commit_notification',
:data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id, :project_name => project_name, :commit_sha => commit_sha} :data => {:user_id => actor.id, :user_name => actor.name, :user_email => actor.email, :project_id => project.id,
:project_name => project_name, :commit_sha => commit_sha, :project_owner => project.owner.uname}
) )
end end
end end
@ -121,7 +124,8 @@ class ActivityFeedObserver < ActiveRecord::Observer
ActivityFeed.create( ActivityFeed.create(
:user => record.user, :user => record.user,
:kind => 'issue_assign_notification', :kind => 'issue_assign_notification',
:data => {:user_name => record.user.name, :user_email => record.user.email, :issue_serial_id => record.serial_id, :project_id => record.project.id, :issue_title => record.title} :data => {:user_name => record.user.name, :user_email => record.user.email, :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 end
end end

View File

@ -1,6 +1,8 @@
.top .top
%span= t('notifications.bodies.delete_branch', {:branch_name => branch_name, :project_name => project_name}) .text
= activity_feed.created_at %span
= t('notifications.bodies.delete_branch', :branch_name => branch_name)
= raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both
%span.date= activity_feed.created_at
.both .both
.fulltext
= link_to(project_name, project_path(project_id))

View File

@ -4,12 +4,11 @@
= image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span %span
= raw t("notifications.bodies.#{change_type}_branch", {:branch_name => branch_name}) = raw t("notifications.bodies.#{change_type}_branch", {:branch_name => branch_name, :user_link => defined?(user_name) ? link_to(user_name, user_path(user_id)) : user_email})
= raw t("notifications.bodies.project", :project_link => link_to(project_name, project_path(project_id))) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both .both
%span.date= activity_feed.created_at %span.date= activity_feed.created_at
.both .both
%br
%span.subject %span.subject
- last_commits.each do |commit| - last_commits.each do |commit|
= link_to commit[0], commit_path(project_id, commit[0]) = link_to commit[0], commit_path(project_id, commit[0])

View File

@ -1,10 +1,8 @@
.top .top
.image
= image_tag(avatar_url_by_email(activity_feed.user.email, :small), :alt => 'avatar')
.text .text
%span %span
= raw t("notifications.bodies.issue_assign_notification", { :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) = raw t("notifications.bodies.issue_assign_notification", { :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))})
= raw t("notifications.bodies.project", :project_link => link_to(project_name, project_path(project_id))) if defined? project_name = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both .both
%span.date= activity_feed.created_at %span.date= activity_feed.created_at
.both .both

View File

@ -4,9 +4,9 @@
.text .text
%span %span
= raw t("notifications.bodies.new_comment_notification.title", :user_link => link_to(user_name, user_path(user_id)) ) = raw t("notifications.bodies.new_comment_notification.title", :user_link => link_to(user_name, user_path(user_id)) )
= raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id))}) = raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id) + (defined?(comment_id) ? "#comment##{comment_id}" : ''))})
= raw t("notifications.bodies.project", :project_link => link_to(project_name, project_path(project_id))) if defined?(project_name) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both .both
%span.date= activity_feed.created_at %span.date= activity_feed.created_at
.both .both
%span.subject= link_to comment_body, commit_path(project_id, commit_id) + (defined?(comment_id) ? "#comment##{comment_id}" : '') %span.subject= comment_body

View File

@ -4,9 +4,9 @@
.text .text
%span %span
= raw t("notifications.bodies.new_comment_notification.title", {:user_link => link_to(user_name, user_path(user_id))}) = raw t("notifications.bodies.new_comment_notification.title", {:user_link => link_to(user_name, user_path(user_id))})
= raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) = raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id) + (defined?(comment_id) ? "#comment##{comment_id}" : ''))})
= raw t("notifications.bodies.project", :project_link => link_to(project_name, project_path(project_id))) if defined?(project_name) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both .both
%span.date= activity_feed.created_at %span.date= activity_feed.created_at
.both .both
%span.subject= link_to comment_body, project_issue_path(project_id, issue_serial_id) + (defined?(comment_id) ? "#comment##{comment_id}" : '') %span.subject= comment_body

View File

@ -3,9 +3,9 @@
= image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span %span
= raw t("notifications.bodies.new_issue_notification", { :user_link => link_to(user_name, user_path(user_id))}) = raw t("notifications.bodies.new_issue_notification", { :user_link => link_to(user_name, user_path(user_id)), :issue_link => project_issue_path(project_id, issue_serial_id)})
= raw t("notifications.bodies.project", :project_link => link_to(project_name, project_path(project_id))) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both .both
%span.date= activity_feed.created_at %span.date= activity_feed.created_at
.both .both
%span.subject= link_to(issue_title, project_issue_path(project_id, issue_serial_id)) %span.subject= issue_title

View File

@ -4,7 +4,7 @@
.text .text
%span %span
= raw t("notifications.bodies.wiki_new_commit_notification", {:user_link => user_name, :history_link => link_to("wiki", history_project_wiki_index_path(project_id))}) = raw t("notifications.bodies.wiki_new_commit_notification", {:user_link => user_name, :history_link => link_to("wiki", history_project_wiki_index_path(project_id))})
= raw t("notifications.bodies.project", :project_link => link_to(project_name, project_path(project_id))) = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) )
.both .both
%span.date= activity_feed.created_at %span.date= activity_feed.created_at
.both .both

View File

@ -20,19 +20,20 @@ en:
bodies: bodies:
new_comment_notification: new_comment_notification:
title: '%{user_link} has been added a new comment' title: '%{user_link} has been added a new comment'
content: in issue %{issue_link}. content: in issue %{issue_link}
commit_content: in commit %{commit_link}. commit_content: in commit %{commit_link}
new_issue_notification: '%{user_link} has been added an issue' new_issue_notification: '%{user_link} has been added a new <a href="%{issue_link}">issue</a>'
ussue: issue
new_user_notification: new_user_notification:
title: Hello, %{user_name}. title: Hello, %{user_name}.
content: You have been sign up to project «ROSA Build System» and now can sign in. content: You have been sign up to project «ROSA Build System» and now can sign in.
email: ==Your email %{user_email} email: ==Your email %{user_email}
password: ==Your password %{user_password} password: ==Your password %{user_password}
issue_assign_notification: You have been assigned to issue %{issue_link} issue_assign_notification: You have been assigned to issue %{issue_link}
wiki_new_commit_notification: '%{user_link} has been updated wiki %{history_link}' wiki_new_commit_notification: '%{user_link} has been updated %{history_link}'
invite_approve_notification: Invite to ABF invite_approve_notification: Invite to ABF
project: in project %{project_link}. project: in project %{project_link}
delete_branch: Branch %{branch_name} has been deleted delete_branch: Branch %{branch_name} has been deleted
create_branch: created new branch %{branch_name} create_branch: '%{user_link} has been created a new branch %{branch_name}'
update_branch: pushed to branch %{branch_name} update_branch: '%{user_link} has been pushed to branch %{branch_name}'

View File

@ -20,19 +20,20 @@ ru:
bodies: bodies:
new_comment_notification: new_comment_notification:
title: '%{user_link} добавил новый комментарий' title: '%{user_link} добавил новый комментарий'
content: в задаче %{issue_link}. content: в задаче %{issue_link}
commit_content: в коммите %{commit_link}. commit_content: в коммите %{commit_link}
new_issue_notification: '%{user_link} добавил новую задачу' new_issue_notification: '%{user_link} добавил новую <a href="%{issue_link}">задачу</a>'
issue: задачу
new_user_notification: new_user_notification:
title: Здравствуйте, %{user_name}. title: Здравствуйте, %{user_name}.
content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему. content: Вы зарегистрированы на проекте «ROSA Build System» и теперь можете войти в систему.
email: ==Ваш email %{user_email} email: ==Ваш email %{user_email}
password: ==Ваш пароль %{user_password} password: ==Ваш пароль %{user_password}
issue_assign_notification: Вам была назначена задача %{issue_link} issue_assign_notification: Вам была назначена задача %{issue_link}
wiki_new_commit_notification: '%{user_link} обновил wiki %{history_link}' wiki_new_commit_notification: '%{user_link} обновил %{history_link}'
invite_approve_notification: Приглашение в ABF invite_approve_notification: Приглашение в ABF
project: в проекте %{project_link}. project: в проекте %{project_link}
delete_branch: Удалена ветка %{branch_name} delete_branch: Удалена ветка %{branch_name}
create_branch: создал новую ветку %{branch_name} create_branch: '%{user_link} создал новую ветку %{branch_name}'
update_branch: внес изменения в ветку %{branch_name} update_branch: '%{user_link} внес изменения в ветку %{branch_name}'

View File

@ -0,0 +1,8 @@
class TruncateActivityFeed < ActiveRecord::Migration
def up
ActivityFeed.destroy_all
end
def down
end
end