We now do a check on photo deletion to ensure that any associated status messages are also deleted if now empty [Issue #1126]

This commit is contained in:
The Lambda Calculus 2011-08-17 09:01:10 -04:00
parent 636f05bd32
commit 98b71f92ab
2 changed files with 12 additions and 2 deletions

View file

@ -128,7 +128,12 @@ class PhotosController < ApplicationController
format.html do
flash[:notice] = I18n.t 'photos.destroy.notice'
if photo.status_message_guid
respond_with photo, :location => post_path(photo.status_message)
if photo.status_message.empty?
photo.status_message.destroy
respond_with photo, :location => person_photos_path(current_user.person)
else
respond_with photo, :location => post_path(photo.status_message)
end
else
respond_with photo, :location => person_photos_path(current_user.person)
end

View file

@ -134,14 +134,19 @@ class StatusMessage < Post
def comment_email_subject
formatted_message(:plain_text => true)
end
def empty?
self.text.blank? && self.photos == []
end
protected
def message_or_photos_present?
if self.text.blank? && self.photos == []
if self.blank?
errors[:base] << 'Status message requires a message or at least one photo'
end
end
end