From 88c625e3f718eb2dffcae7e8d2d03a86a51cd309 Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 26 Jun 2012 21:47:25 +0300 Subject: [PATCH] Issues can be unassigned now --- app/assets/images/no_avatar.png | Bin 1335 -> 1337 bytes app/models/issue.rb | 6 +++++- app/observers/issue_observer.rb | 6 ++++-- app/views/issues/_form.html.haml | 2 +- app/views/issues/_show.html.haml | 22 +++++++++++++++------- app/views/issues/show.html.haml | 7 ++++--- app/views/milestones/show.html.haml | 2 -- spec/models/issue_spec.rb | 1 - 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/assets/images/no_avatar.png b/app/assets/images/no_avatar.png index 99e5fd9b4369ac3022d4a30890060635466ecb9c..752d26adba7aa91b8e32685cd5ded666da5c9a69 100644 GIT binary patch delta 1305 zcmV+!1?Kv<3b_i9F@FYPOGiWi{{a60|De66lK=n!32;bRa{vGf6951U69E94oEQKA z00(qQO+^RX1{xA73;x$u5dZ)Lxk*GpRCwCmTgz_hFc2kRFce-I$ zfl5&kN%M5<_%0$LbOV9lF%8VFh#DWyS(eGKndf7n(+z zroCS8k9BzHB$DoTH0rd7Ef`}U9(X8}QpOm@_>cW??=~u^Reo78gy1F$wJZV*42sgD zw)o+Hb;G0SPza$;hmtG9=&&dXMF`8qWfC_S9U_D%rGF~mF~$%=e{ZE_wXR5ql9d!# zq`?@gAPh;mhhz)OvQ)UDd|rwHx8nOgtgUj+|334Es#Dc1i(2I~Dozb@PnKmJb|2)W z+wHcZ#@~zMIDp}_C<@1M+Jz97Fc@Q&Wwi?-lwHAkHE?VIbVaDc0@k79IOSD@d`ThC zgsrwx#(x+TLil?N!!YF2H^5XL9-(QP@_k{zhy{Od0m6zPJfTX5yqM&alI-X zg4h@&uc|+E)2a-}++H*}#_w@ASy6%Nhw*f-Vd4CWDyWQ@Rd<7vi9*>*aRTzfr_4*QmK?o5- z2q9;2UWzab!_8*Xv4LgpeA$J&!QY^Y8EPGCW+@ zkFaffFc{djT|Mt|NG}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H+L)f6<{ucnkUsR40fzPBHRz7-g}XbUI??yNwC;u*?aa)~#KgqZ)YPy4 z%jD$b`1m;2sY!ivk17hOP5k9aYLvRgxkfOh5MFXF9TaSQ!tSEuXky9lNhqPJqt+v8 zw}xvHdRyX=PFQm62T@cKPnD)q(yQ4a$$tV>eNj`H&;t}nm0b!A5*v4INE1yjQ4U_o z9sN{Lfsj&{8V@LWeCI1MR^vworkFUQe%;hjHqTKB#U!@(6-5;p(V2!BTv7ddiE7cy z<90Zq-?l1fRiE7%&mpGEpT6tuLthzSSnWs1&yu1wgi!SpHjdFDA_`bjG{ybHpMN20 zDX~C{ilnNaiteP=jwcp=*>>92*-eTAjZ& zMi|2+hB2?CF*Tg9SR4H{>r`}d8zPKh($N2MGAdz?Hwr&T=j$i@7fXu8V-WhHY)$|G N002ovPDHLkV1gG3ZL9zQ diff --git a/app/models/issue.rb b/app/models/issue.rb index fa2aa2f40..40e14dac0 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -11,7 +11,6 @@ class Issue < ActiveRecord::Base attr_accessor :author_id_of_changes validates_presence_of :project_id - validates_presence_of :assignee_id validates_presence_of :author_id delegate :name, @@ -22,6 +21,7 @@ class Issue < ActiveRecord::Base delegate :name, :email, :to => :assignee, + :allow_nil => true, :prefix => true validates :title, @@ -56,6 +56,10 @@ class Issue < ActiveRecord::Base today? && created_at == updated_at end + def is_assigned? + !!assignee_id + end + def is_being_reassigned? assignee_id_changed? end diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb index fadedd301..92b0f8368 100644 --- a/app/observers/issue_observer.rb +++ b/app/observers/issue_observer.rb @@ -2,7 +2,9 @@ class IssueObserver < ActiveRecord::Observer cattr_accessor :current_user def after_create(issue) - Notify.new_issue_email(issue.id).deliver if issue.assignee != current_user + if issue.assignee && issue.assignee != current_user + Notify.new_issue_email(issue.id).deliver + end end def after_update(issue) @@ -14,7 +16,7 @@ class IssueObserver < ActiveRecord::Observer protected def send_reassigned_email(issue) - recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id != current_user.id } + recipient_ids = [issue.assignee_id, issue.assignee_id_was].keep_if {|id| id && id != current_user.id } recipient_ids.each do |recipient_id| Notify.reassigned_issue_email(recipient_id, issue.id, issue.assignee_id_was).deliver diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index 4dcba4fb6..444fbd768 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -14,7 +14,7 @@ = f.text_field :title, :maxlength => 255, :class => "xxlarge" .issue_middle_block .issue_assignee - = f.label :assignee_id, "Assign to *" + = f.label :assignee_id, "Assign to" .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Assign to user" }) .issue_milestone = f.label :milestone_id diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index de2755595..b6b5d72d5 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -15,12 +15,20 @@ %i.icon-edit Edit - = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" - %span.update-author - assigned to - %strong= issue.assignee_name - - if issue.upvotes > 0 - %span.badge.badge-success= "+#{issue.upvotes}" - + - if issue.assignee + = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" + %span.update-author + assigned to + %strong= issue.assignee_name + - if issue.upvotes > 0 + %span.badge.badge-success= "+#{issue.upvotes}" + + - else + = image_tag "no_avatar.png", :class => "avatar" + %span.update-author + Unassigned + - if issue.upvotes > 0 + %span.badge.badge-success= "+#{issue.upvotes}" + = link_to project_issue_path(issue.project, issue) do %p.row_title= truncate(issue.title, :length => 100) diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 0d3c4e190..1bb4e04d2 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -38,9 +38,10 @@ = image_tag gravatar_icon(@issue.author_email), :width => 16, :class => "lil_av" %strong.author= link_to_issue_author(@issue) - %cite.cgray and currently assigned to - = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" - %strong.author= link_to_issue_assignee(@issue) + - if @issue.assignee + %cite.cgray and currently assigned to + = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" + %strong.author= link_to_issue_assignee(@issue) - if @issue.milestone - milestone = @issue.milestone diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index dccfe625d..727fa0fd1 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -49,8 +49,6 @@ %tr %td = link_to [@project, issue] do - = image_tag gravatar_icon(issue.assignee_email, 16), :width => "16" -   %span.badge.badge-info ##{issue.id} – = truncate issue.title, :length => 60 diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 486b9f656..fbd4031fa 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -12,7 +12,6 @@ describe Issue do it { should validate_presence_of(:title) } it { should validate_presence_of(:author_id) } it { should validate_presence_of(:project_id) } - it { should validate_presence_of(:assignee_id) } end describe "Scope" do -- 2.11.0