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:
parent
636f05bd32
commit
98b71f92ab
2 changed files with 12 additions and 2 deletions
|
|
@ -128,7 +128,12 @@ class PhotosController < ApplicationController
|
||||||
format.html do
|
format.html do
|
||||||
flash[:notice] = I18n.t 'photos.destroy.notice'
|
flash[:notice] = I18n.t 'photos.destroy.notice'
|
||||||
if photo.status_message_guid
|
if photo.status_message_guid
|
||||||
|
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)
|
respond_with photo, :location => post_path(photo.status_message)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
respond_with photo, :location => person_photos_path(current_user.person)
|
respond_with photo, :location => person_photos_path(current_user.person)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -136,12 +136,17 @@ class StatusMessage < Post
|
||||||
formatted_message(:plain_text => true)
|
formatted_message(:plain_text => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def empty?
|
||||||
|
self.text.blank? && self.photos == []
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def message_or_photos_present?
|
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'
|
errors[:base] << 'Status message requires a message or at least one photo'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue