From e0efaa6317c8e64833567228ff25a1cb6467083b Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 29 Nov 2010 10:57:54 -0800 Subject: [PATCH 1/2] made the checking for already connected more explicit. also, the check itself had a bug when we were calling self.to_id on a request, rather than self.to.id --- app/helpers/requests_helper.rb | 1 - app/models/request.rb | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 8c8a1e387..52e9043f7 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -13,5 +13,4 @@ module RequestsHelper link_to t('new_requests', :count => @request_count), aspects_manage_path end end - end diff --git a/app/models/request.rb b/app/models/request.rb index ca33c5dc0..dbf9a62fb 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -19,7 +19,8 @@ class Request key :sent, Boolean, :default => false validates_presence_of :from, :to - validate :not_already_connected, :if => :sent + validate :not_already_connected_if_sent + validate :not_already_connected_if_not_sent validate :no_pending_request, :if => :sent #before_validation :clean_link @@ -91,9 +92,19 @@ class Request end end - def not_already_connected - if Contact.first(:user_id => self.from.owner_id, :person_id => self.to_id) - errors[:base] << 'You have already connected to this person!' + def not_already_connected_if_sent + if self.sent + if Contact.first(:user_id => self.from.owner_id, :person_id => self.to.id) + errors[:base] << 'You have already connected to this person!' + end + end + end + + def not_already_connected_if_not_sent + unless self.sent + if Contact.first(:user_id => self.to.owner_id, :person_id => self.from.id) + errors[:base] << 'You have already connected to this person!' + end end end end From 760fed70165ee5f4c0c174724a102177fb78690e Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 29 Nov 2010 12:10:41 -0800 Subject: [PATCH 2/2] No need for defined? --- app/views/comments/_comments.html.haml | 2 +- app/views/shared/_stream_element.html.haml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index 7b34eb05e..5d567aa33 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -2,7 +2,7 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -%ul.comments{:id => post_id, :class => ("hidden" if defined?(hidden) && hidden)} +%ul.comments{:id => post_id, :class => ("hidden" if comment_hashes.size == 0)} - for comment_hash in comment_hashes = render 'comments/comment', comment_hash %li.comment.show diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 2c9d00c3d..7886fd040 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -25,11 +25,11 @@ = render 'shared/reshare', :current_user => current_user, :post => post if post.is_a? StatusMessage = link_to t('delete'), object_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete" - = render type_partial(post), :post => post + = render 'status_messages/status_message', :post => post .info - %span.time= link_to(how_long_ago(post), object_path(post)) + %span.time= link_to(how_long_ago(post), status_message_path(post)) = comment_toggle(comments.length) - = render "comments/comments", :post_id => post.id, :comment_hashes => comments, :hidden => (comments.length == 0) + = render "comments/comments", :post_id => post.id, :comment_hashes => comments