Revision 5aa80ef6
Added by Marc Dequènes over 15 years ago
- ID 5aa80ef6dfda9e07cb9c8359a9f94bec17214ca3
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
|
lib/ldap_shadows/object.rb | ||
---|---|---|
end
|
||
|
||
def save
|
||
check_hooks
|
||
before_save_jobs
|
||
super
|
||
end
|
||
|
||
def save!
|
||
check_hooks
|
||
before_save_jobs
|
||
super
|
||
end
|
||
|
||
protected
|
||
|
||
def before_save_jobs
|
||
check_hooks
|
||
check_missing_attributes
|
||
end
|
||
|
||
def check_hooks
|
||
self.aspects.each do |aspect|
|
||
aklass = self.class.mapper.get_aspect_klass(aspect)
|
||
... | ... | |
end
|
||
end
|
||
|
||
def check_missing_attributes
|
||
missing_fields = self.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 item; the following fields are missing: %s") %
|
||
miss_str.join(", ")
|
||
end
|
||
end
|
||
|
||
def fetch_attributes_data(attr_list, expert_attributes)
|
||
attr_data = self.attributes.collect do |key, val|
|
||
if attr_list.include?(key)
|
Also available in: Unified diff
[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)