Commit bed70a93f51cda78e7a4b9adae75d10c3763af30
Exists in
master
and in
4 other branches
Merge branch 'master' of dev.gitlabhq.com:gitlabhq
Showing
15 changed files
with
102 additions
and
23 deletions
Show diff stats
app/assets/stylesheets/common.scss
app/controllers/issues_controller.rb
... | ... | @@ -76,7 +76,7 @@ class IssuesController < ApplicationController |
76 | 76 | end |
77 | 77 | |
78 | 78 | def update |
79 | - @issue.update_attributes(params[:issue]) | |
79 | + @issue.update_attributes(params[:issue].merge(:author_id_of_changes => current_user.id)) | |
80 | 80 | |
81 | 81 | respond_to do |format| |
82 | 82 | format.js | ... | ... |
app/controllers/merge_requests_controller.rb
... | ... | @@ -87,7 +87,7 @@ class MergeRequestsController < ApplicationController |
87 | 87 | |
88 | 88 | def update |
89 | 89 | respond_to do |format| |
90 | - if @merge_request.update_attributes(params[:merge_request]) | |
90 | + if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id)) | |
91 | 91 | format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' } |
92 | 92 | format.json { head :ok } |
93 | 93 | else | ... | ... |
app/models/activity_observer.rb
1 | 1 | class ActivityObserver < ActiveRecord::Observer |
2 | - observe :issue, :merge_request, :note | |
2 | + observe :issue, :merge_request | |
3 | 3 | |
4 | 4 | def after_create(record) |
5 | 5 | Event.create( |
6 | 6 | :project => record.project, |
7 | 7 | :target_id => record.id, |
8 | 8 | :target_type => record.class.name, |
9 | - :action => Event.determine_action(record) | |
9 | + :action => Event.determine_action(record), | |
10 | + :author_id => record.author_id | |
10 | 11 | ) |
11 | 12 | end |
13 | + | |
14 | + def after_save(record) | |
15 | + if record.changed.include?("closed") | |
16 | + Event.create( | |
17 | + :project => record.project, | |
18 | + :target_id => record.id, | |
19 | + :target_type => record.class.name, | |
20 | + :action => (record.closed ? Event::Closed : Event::Reopened), | |
21 | + :author_id => record.author_id_of_changes | |
22 | + ) | |
23 | + end | |
24 | + end | |
12 | 25 | end | ... | ... |
app/models/event.rb
1 | 1 | class Event < ActiveRecord::Base |
2 | + default_scope where("author_id IS NOT NULL") | |
3 | + | |
2 | 4 | Created = 1 |
3 | 5 | Updated = 2 |
4 | 6 | Closed = 3 |
... | ... | @@ -26,13 +28,22 @@ class Event < ActiveRecord::Base |
26 | 28 | # - new issue |
27 | 29 | # - merge request |
28 | 30 | def allowed? |
29 | - push? || new_issue? || new_merge_request? | |
31 | + push? || new_issue? || new_merge_request? || | |
32 | + changed_merge_request? || changed_issue? | |
30 | 33 | end |
31 | 34 | |
32 | 35 | def push? |
33 | 36 | action == self.class::Pushed |
34 | 37 | end |
35 | 38 | |
39 | + def closed? | |
40 | + action == self.class::Closed | |
41 | + end | |
42 | + | |
43 | + def reopened? | |
44 | + action == self.class::Reopened | |
45 | + end | |
46 | + | |
36 | 47 | def new_tag? |
37 | 48 | data[:ref]["refs/tags"] |
38 | 49 | end |
... | ... | @@ -57,10 +68,6 @@ class Event < ActiveRecord::Base |
57 | 68 | @tag_name ||= data[:ref].gsub("refs/tags/", "") |
58 | 69 | end |
59 | 70 | |
60 | - def pusher | |
61 | - User.find_by_id(data[:user_id]) | |
62 | - end | |
63 | - | |
64 | 71 | def new_issue? |
65 | 72 | target_type == "Issue" && |
66 | 73 | action == Created |
... | ... | @@ -71,6 +78,16 @@ class Event < ActiveRecord::Base |
71 | 78 | action == Created |
72 | 79 | end |
73 | 80 | |
81 | + def changed_merge_request? | |
82 | + target_type == "MergeRequest" && | |
83 | + [Closed, Reopened].include?(action) | |
84 | + end | |
85 | + | |
86 | + def changed_issue? | |
87 | + target_type == "Issue" && | |
88 | + [Closed, Reopened].include?(action) | |
89 | + end | |
90 | + | |
74 | 91 | def issue |
75 | 92 | target if target_type == "Issue" |
76 | 93 | end |
... | ... | @@ -80,7 +97,7 @@ class Event < ActiveRecord::Base |
80 | 97 | end |
81 | 98 | |
82 | 99 | def author |
83 | - target.author | |
100 | + @author ||= User.find(author_id) | |
84 | 101 | end |
85 | 102 | |
86 | 103 | def commits |
... | ... | @@ -89,7 +106,6 @@ class Event < ActiveRecord::Base |
89 | 106 | end |
90 | 107 | end |
91 | 108 | |
92 | - delegate :id, :name, :email, :to => :pusher, :prefix => true, :allow_nil => true | |
93 | 109 | delegate :name, :email, :to => :author, :prefix => true, :allow_nil => true |
94 | 110 | delegate :title, :to => :issue, :prefix => true, :allow_nil => true |
95 | 111 | delegate :title, :to => :merge_request, :prefix => true, :allow_nil => true | ... | ... |
app/models/issue.rb
... | ... | @@ -5,6 +5,7 @@ class Issue < ActiveRecord::Base |
5 | 5 | has_many :notes, :as => :noteable, :dependent => :destroy |
6 | 6 | |
7 | 7 | attr_protected :author, :author_id, :project, :project_id |
8 | + attr_accessor :author_id_of_changes | |
8 | 9 | |
9 | 10 | validates_presence_of :project_id |
10 | 11 | validates_presence_of :assignee_id | ... | ... |
app/models/merge_request.rb
... | ... | @@ -5,6 +5,7 @@ class MergeRequest < ActiveRecord::Base |
5 | 5 | has_many :notes, :as => :noteable, :dependent => :destroy |
6 | 6 | |
7 | 7 | attr_protected :author, :author_id, :project, :project_id |
8 | + attr_accessor :author_id_of_changes | |
8 | 9 | |
9 | 10 | validates_presence_of :project_id |
10 | 11 | validates_presence_of :assignee_id | ... | ... |
app/models/project.rb
... | ... | @@ -68,7 +68,8 @@ class Project < ActiveRecord::Base |
68 | 68 | Event.create( |
69 | 69 | :project => self, |
70 | 70 | :action => Event::Pushed, |
71 | - :data => data | |
71 | + :data => data, | |
72 | + :author_id => Key.find_by_identifier(author_key_id).user.id | |
72 | 73 | ) |
73 | 74 | end |
74 | 75 | |
... | ... | @@ -259,7 +260,7 @@ class Project < ActiveRecord::Base |
259 | 260 | |
260 | 261 | def commit(commit_id = nil) |
261 | 262 | commit = if commit_id |
262 | - repo.commits(commit_id).first | |
263 | + repo.commit(commit_id) | |
263 | 264 | else |
264 | 265 | repo.commits.first |
265 | 266 | end | ... | ... |
app/views/dashboard/index.html.haml
... | ... | @@ -20,8 +20,8 @@ |
20 | 20 | .row |
21 | 21 | .dashboard_block |
22 | 22 | .row |
23 | - .span9= render "dashboard/projects_feed" | |
24 | - .span3.right | |
23 | + .span10= render "dashboard/projects_feed" | |
24 | + .span4.right | |
25 | 25 | - if current_user.can_create_project? |
26 | 26 | .alert-message.block-message.warning |
27 | 27 | You can create up to | ... | ... |
app/views/events/_event.html.haml
... | ... | @@ -2,7 +2,11 @@ |
2 | 2 | .event_feed |
3 | 3 | - if event.new_issue? |
4 | 4 | = render "events/event_new_issue", :event => event |
5 | - - if event.new_merge_request? | |
5 | + - elsif event.new_merge_request? | |
6 | 6 | = render "events/event_new_merge_request", :event => event |
7 | + - elsif event.changed_merge_request? | |
8 | + = render "events/event_changed_merge_request", :event => event | |
9 | + - elsif event.changed_issue? | |
10 | + = render "events/event_changed_issue", :event => event | |
7 | 11 | - elsif event.push? |
8 | 12 | = render "events/event_push", :event => event | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | += image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | +%strong #{event.author_name} | |
3 | +- if event.closed? | |
4 | + closed | |
5 | +- else | |
6 | + reopened | |
7 | +issue | |
8 | += link_to project_issue_path(event.project, event.issue) do | |
9 | + %strong= truncate event.issue_title | |
10 | +at | |
11 | +%strong= link_to event.project.name, event.project | |
12 | +%span.cgray | |
13 | + = time_ago_in_words(event.created_at) | |
14 | + ago. | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | += image_tag gravatar_icon(event.author_email), :class => "avatar" | |
2 | +%strong #{event.author_name} | |
3 | +- if event.closed? | |
4 | + closed | |
5 | +- else | |
6 | + reopened | |
7 | +merge request | |
8 | += link_to project_merge_request_path(event.project, event.merge_request) do | |
9 | + %strong= truncate event.merge_request_title | |
10 | +at | |
11 | +%strong= link_to event.project.name, event.project | |
12 | +%span.cgray | |
13 | + = time_ago_in_words(event.created_at) | |
14 | + ago. | |
15 | +%br | |
16 | +%span.label= event.merge_request.source_branch | |
17 | +→ | |
18 | +%span.label= event.merge_request.target_branch | |
19 | + | ... | ... |
app/views/events/_event_push.html.haml
1 | 1 | - if event.new_branch? || event.new_tag? |
2 | - = image_tag gravatar_icon(event.pusher_email), :class => "avatar" | |
3 | - %strong #{event.pusher_name} | |
2 | + = image_tag gravatar_icon(event.author_email), :class => "avatar" | |
3 | + %strong #{event.author_name} | |
4 | 4 | pushed new |
5 | 5 | - if event.new_tag? |
6 | 6 | tag |
... | ... | @@ -16,8 +16,8 @@ |
16 | 16 | = time_ago_in_words(event.created_at) |
17 | 17 | ago. |
18 | 18 | - else |
19 | - = image_tag gravatar_icon(event.pusher_email), :class => "avatar" | |
20 | - %strong #{event.pusher_name} | |
19 | + = image_tag gravatar_icon(event.author_email), :class => "avatar" | |
20 | + %strong #{event.author_name} | |
21 | 21 | pushed to |
22 | 22 | = link_to project_commits_path(event.project, :ref => event.branch_name) do |
23 | 23 | %strong= event.branch_name |
... | ... | @@ -31,6 +31,10 @@ |
31 | 31 | Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]} |
32 | 32 | - @project = event.project |
33 | 33 | %ul.unstyled |
34 | - = render event.commits | |
34 | + - if event.commits.size > 4 | |
35 | + = render event.commits[0..2] | |
36 | + %li ... and #{event.commits.size - 3} more commits | |
37 | + - else | |
38 | + = render event.commits | |
35 | 39 | |
36 | 40 | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(:version => 20120301185805) do | |
14 | +ActiveRecord::Schema.define(:version => 20120307095918) do | |
15 | 15 | |
16 | 16 | create_table "events", :force => true do |t| |
17 | 17 | t.string "target_type" |
... | ... | @@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20120301185805) do |
22 | 22 | t.datetime "created_at", :null => false |
23 | 23 | t.datetime "updated_at", :null => false |
24 | 24 | t.integer "action" |
25 | + t.integer "author_id" | |
25 | 26 | end |
26 | 27 | |
27 | 28 | create_table "issues", :force => true do |t| | ... | ... |