[refs #265] Fix git push and delete branch partials and logic

This commit is contained in:
konstantin.grabar 2012-03-06 18:57:05 +04:00
parent f54d889f74
commit 7e53a6c511
3 changed files with 23 additions and 21 deletions

View File

@ -68,17 +68,18 @@ class ActivityFeedObserver < ActiveRecord::Observer
project = Project.find_by_name(record.repo)
last_commits = project.git_repository.repo.log(branch_name, nil).first(3)
first_commiter = User.find_by_email(last_commits[0].author.email) if last_commits.size > 0
first_commiter = User.find_by_email(last_commits[0].author.email) unless last_commits.blank?
last_commits = last_commits.collect do |commit| #:author => 'author'
[commit.sha, commit.message]
end
if change_type == 'delete'
kind = 'git_delete_branch_notification'
options = {:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email, :project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type}
options = {:project_id => project.id, :project_name => project.name, :branch_name => branch_name, :change_type => change_type}
else
kind = 'git_new_push_notification'
options = {:project_id => project.id, :project_name => project.name, :last_commits => last_commits, :branch_name => branch_name, :change_type => change_type}
options.merge!({:user_id => first_commiter.id, :user_name => first_commiter.name, :user_email => first_commiter.email}) if first_commiter
end
project.owner_and_admin_ids.each do |recipient|

View File

@ -1,13 +1,7 @@
.top
.image
=# image_tag(gravatar_url(activity_feed.user.email, 30))
.text
%span.name
=# link_to activity_feed.user.uname, user_path(activity_feed.user.uname)
%br
%span.date= activity_feed.created_at
%br
%span.subject Branch #{ branch_name } has been deleted
%span.date= activity_feed.created_at
%br
%span.subject Branch #{ branch_name } has been deleted
.both
.fulltext
Into project #{ link_to(project_name, project_path(project_id)) }

View File

@ -1,15 +1,22 @@
.top
.image
= image_tag(gravatar_url(user_email, 30))
.text
%span.name
= link_to user_name, user_path(user_id)
%br
%span.date= activity_feed.created_at
- if defined? user_email
.top
.image
= image_tag(gravatar_url(user_email, 30))
.text
%span.name
= link_to user_name, user_path(user_id)
%br
%span.subject Branch #{ branch_name } has been #{ change_type }d
.both
%span.date= activity_feed.created_at
%br
%span.subject Branch #{ branch_name } has been #{ change_type }d
.both
.fulltext
- unless defined? user_email
%span.date= activity_feed.created_at
%br
Branch #{ branch_name } has been #{ change_type }d
%br
%br
Into project #{ link_to(project_name, project_path(project_id)) }
%br
%br