Project

General

Profile

« Previous | Next » 

Revision 5aa80ef6

Added by Marc Dequènes over 15 years ago

  • ID 5aa80ef6dfda9e07cb9c8359a9f94bec17214ca3

[fix] move missing attribute check into the save() method to ensure it is done after hooks (which can modify attributes and change the result of the test)

View differences:

bin/shadowwalker
end
if modification_done
missing_fields = item.missing_attributes
unless missing_fields.empty?
miss_str = []
missing_fields.each do |field|
str = Translator.translate_field_name(field)
str += " [#{field}]" if $program_options[:handles]
miss_str << str
end
raise PreProcessingError, _("Cannot save the modifications; the following fields are missing: %s") %
miss_str.join(", ")
end
item.save!
puts "Modification done."
else
puts "Nothing to do."
......
item.send(field + "=", val)
end
missing_fields = item.missing_attributes
unless missing_fields.empty?
miss_str = []
missing_fields.each do |field|
str = Translator.translate_field_name(field)
str += " [#{field}]" if $program_options[:handles]
miss_str << str
end
raise PreProcessingError, _("Cannot save the new item; the following fields are missing: %s") %
miss_str.join(", ")
end
item.save!
end
end

Also available in: Unified diff