Commit 88c625e3f718eb2dffcae7e8d2d03a86a51cd309
1 parent
6abc6495
Exists in
master
and in
4 other branches
Issues can be unassigned now
Showing
8 changed files
with
29 additions
and
17 deletions
Show diff stats
app/assets/images/no_avatar.png
app/models/issue.rb
@@ -11,7 +11,6 @@ class Issue < ActiveRecord::Base | @@ -11,7 +11,6 @@ class Issue < ActiveRecord::Base | ||
11 | attr_accessor :author_id_of_changes | 11 | attr_accessor :author_id_of_changes |
12 | 12 | ||
13 | validates_presence_of :project_id | 13 | validates_presence_of :project_id |
14 | - validates_presence_of :assignee_id | ||
15 | validates_presence_of :author_id | 14 | validates_presence_of :author_id |
16 | 15 | ||
17 | delegate :name, | 16 | delegate :name, |
@@ -22,6 +21,7 @@ class Issue < ActiveRecord::Base | @@ -22,6 +21,7 @@ class Issue < ActiveRecord::Base | ||
22 | delegate :name, | 21 | delegate :name, |
23 | :email, | 22 | :email, |
24 | :to => :assignee, | 23 | :to => :assignee, |
24 | + :allow_nil => true, | ||
25 | :prefix => true | 25 | :prefix => true |
26 | 26 | ||
27 | validates :title, | 27 | validates :title, |
@@ -56,6 +56,10 @@ class Issue < ActiveRecord::Base | @@ -56,6 +56,10 @@ class Issue < ActiveRecord::Base | ||
56 | today? && created_at == updated_at | 56 | today? && created_at == updated_at |
57 | end | 57 | end |
58 | 58 | ||
59 | + def is_assigned? | ||
60 | + !!assignee_id | ||
61 | + end | ||
62 | + | ||
59 | def is_being_reassigned? | 63 | def is_being_reassigned? |
60 | assignee_id_changed? | 64 | assignee_id_changed? |
61 | end | 65 | end |
app/observers/issue_observer.rb
@@ -2,7 +2,9 @@ class IssueObserver < ActiveRecord::Observer | @@ -2,7 +2,9 @@ class IssueObserver < ActiveRecord::Observer | ||
2 | cattr_accessor :current_user | 2 | cattr_accessor :current_user |
3 | 3 | ||
4 | def after_create(issue) | 4 | def after_create(issue) |
5 | - Notify.new_issue_email(issue.id).deliver if issue.assignee != current_user | 5 | + if issue.assignee && issue.assignee != current_user |
6 | + Notify.new_issue_email(issue.id).deliver | ||
7 | + end | ||
6 | end | 8 | end |
7 | 9 | ||
8 | def after_update(issue) | 10 | def after_update(issue) |
@@ -14,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer | @@ -14,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer | ||
14 | protected | 16 | protected |
15 | 17 | ||
16 | def send_reassigned_email(issue) | 18 | def send_reassigned_email(issue) |
17 | - recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id } | 19 | + recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id } |
18 | 20 | ||
19 | recipient_ids.each do |recipient_id| | 21 | recipient_ids.each do |recipient_id| |
20 | Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver | 22 | Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver |
app/views/issues/_form.html.haml
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | = f.text_field :title, :maxlength => 255, :class => "xxlarge" | 14 | = f.text_field :title, :maxlength => 255, :class => "xxlarge" |
15 | .issue_middle_block | 15 | .issue_middle_block |
16 | .issue_assignee | 16 | .issue_assignee |
17 | - = f.label :assignee_id, "Assign to *" | 17 | + = f.label :assignee_id, "Assign to" |
18 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" }) | 18 | .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" }) |
19 | .issue_milestone | 19 | .issue_milestone |
20 | = f.label :milestone_id | 20 | = f.label :milestone_id |
app/views/issues/_show.html.haml
@@ -15,12 +15,20 @@ | @@ -15,12 +15,20 @@ | ||
15 | %i.icon-edit | 15 | %i.icon-edit |
16 | Edit | 16 | Edit |
17 | 17 | ||
18 | - = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" | ||
19 | - %span.update-author | ||
20 | - assigned to | ||
21 | - %strong= issue.assignee_name | ||
22 | - - if issue.upvotes > 0 | ||
23 | - %span.badge.badge-success= "+#{issue.upvotes}" | ||
24 | - | 18 | + - if issue.assignee |
19 | + = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" | ||
20 | + %span.update-author | ||
21 | + assigned to | ||
22 | + %strong= issue.assignee_name | ||
23 | + - if issue.upvotes > 0 | ||
24 | + %span.badge.badge-success= "+#{issue.upvotes}" | ||
25 | + | ||
26 | + - else | ||
27 | + = image_tag "no_avatar.png", :class => "avatar" | ||
28 | + %span.update-author | ||
29 | + Unassigned | ||
30 | + - if issue.upvotes > 0 | ||
31 | + %span.badge.badge-success= "+#{issue.upvotes}" | ||
32 | + | ||
25 | = link_to project_issue_path(issue.project, issue) do | 33 | = link_to project_issue_path(issue.project, issue) do |
26 | %p.row_title= truncate(issue.title, :length => 100) | 34 | %p.row_title= truncate(issue.title, :length => 100) |
app/views/issues/show.html.haml
@@ -38,9 +38,10 @@ | @@ -38,9 +38,10 @@ | ||
38 | = image_tag gravatar_icon(@issue.author_email), :width => 16, :class => "lil_av" | 38 | = image_tag gravatar_icon(@issue.author_email), :width => 16, :class => "lil_av" |
39 | %strong.author= link_to_issue_author(@issue) | 39 | %strong.author= link_to_issue_author(@issue) |
40 | 40 | ||
41 | - %cite.cgray and currently assigned to | ||
42 | - = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" | ||
43 | - %strong.author= link_to_issue_assignee(@issue) | 41 | + - if @issue.assignee |
42 | + %cite.cgray and currently assigned to | ||
43 | + = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" | ||
44 | + %strong.author= link_to_issue_assignee(@issue) | ||
44 | 45 | ||
45 | - if @issue.milestone | 46 | - if @issue.milestone |
46 | - milestone = @issue.milestone | 47 | - milestone = @issue.milestone |
app/views/milestones/show.html.haml
@@ -49,8 +49,6 @@ | @@ -49,8 +49,6 @@ | ||
49 | %tr | 49 | %tr |
50 | %td | 50 | %td |
51 | = link_to [@project, issue] do | 51 | = link_to [@project, issue] do |
52 | - = image_tag gravatar_icon(issue.assignee_email, 16), :width => "16" | ||
53 | - | ||
54 | %span.badge.badge-info ##{issue.id} | 52 | %span.badge.badge-info ##{issue.id} |
55 | – | 53 | – |
56 | = truncate issue.title, :length => 60 | 54 | = truncate issue.title, :length => 60 |
spec/models/issue_spec.rb
@@ -12,7 +12,6 @@ describe Issue do | @@ -12,7 +12,6 @@ describe Issue do | ||
12 | it { should validate_presence_of(:title) } | 12 | it { should validate_presence_of(:title) } |
13 | it { should validate_presence_of(:author_id) } | 13 | it { should validate_presence_of(:author_id) } |
14 | it { should validate_presence_of(:project_id) } | 14 | it { should validate_presence_of(:project_id) } |
15 | - it { should validate_presence_of(:assignee_id) } | ||
16 | end | 15 | end |
17 | 16 | ||
18 | describe "Scope" do | 17 | describe "Scope" do |