Skip to content
Extraits de code Groupes Projets
Valider 98b71f92 rédigé par The Lambda Calculus's avatar The Lambda Calculus
Parcourir les fichiers

We now do a check on photo deletion to ensure that any associated status...

We now do a check on photo deletion to ensure that any associated status messages are also deleted if now empty [Issue #1126]
parent 636f05bd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter