application error when submitting an asset without a name
This commit is contained in:
parent
50f06a7b85
commit
2ba0718647
@ -4,7 +4,7 @@
|
||||
|
||||
= f.inputs :name => :information do
|
||||
= f.input :name
|
||||
= f.input :source, :hint => preserve(t("formtastic.hints.asset.#{action_name}.source", :url => link_to(@asset.source_filename, @asset.source.url)))
|
||||
= f.input :source, :hint_options => { :url => link_to(@asset.source_filename, @asset.source.url), :escaping => false }
|
||||
|
||||
- unless @asset.custom_fields.blank?
|
||||
= render 'admin/custom_fields/custom_form', :form => f, :title => :other_fields, :parent => @asset_collection
|
||||
|
@ -61,10 +61,11 @@ en:
|
||||
edit:
|
||||
source: "You can replace it by a file of the same extension"
|
||||
asset:
|
||||
new:
|
||||
source: "All file types are accepted."
|
||||
source: "All file types are accepted."
|
||||
edit:
|
||||
source: "The current file is available here %{url}"
|
||||
update:
|
||||
source: "The current file is available here %{url}"
|
||||
custom_fields:
|
||||
field:
|
||||
_alias: "Property available in liquid templates"
|
||||
|
@ -64,10 +64,11 @@ fr:
|
||||
edit:
|
||||
source: "Vous pouvez le remplacer par un fichier avec la meme extension."
|
||||
asset:
|
||||
new:
|
||||
source: "Tous les types de fichier sont acceptés."
|
||||
source: "Tous les types de fichier sont acceptés."
|
||||
edit:
|
||||
source: "Le fichier actuel est accessible ici %{url}"
|
||||
update:
|
||||
source: "Le fichier actuel est accessible ici %{url}"
|
||||
custom_fields:
|
||||
field:
|
||||
_alias: "Champ utilisable dans les templates liquid"
|
||||
|
13
doc/TODO
13
doc/TODO
@ -1,10 +1,9 @@
|
||||
BOARD:
|
||||
|
||||
x pull request #44
|
||||
- bugs:
|
||||
- #50
|
||||
- #51
|
||||
~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag
|
||||
x bug on dates (https://github.com/locomotivecms/engine/issues#issue/48)
|
||||
x generated sitemaps are invalid (url + date)
|
||||
- integrate new locomotivecms home
|
||||
- duostack version
|
||||
- 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa)
|
||||
- seo section for the page form: seo title, seo keywords, seo description
|
||||
@ -206,4 +205,8 @@ x bugs
|
||||
x uploading videos http://groups.google.com/group/carrierwave/browse_thread/thread/6e211d98f1ff4bc0/51717c2167695ca2?lnk=gst&q=version#51717c2167695ca2
|
||||
x custom fields: accepts_nested_attributes weird behaviour when creating new content type + adding random fields
|
||||
x better icons for mime type (css3)
|
||||
x validation for custom fields: required done
|
||||
x validation for custom fields: required done
|
||||
x pull request #44
|
||||
x bug on dates (https://github.com/locomotivecms/engine/issues#issue/48)
|
||||
x generated sitemaps are invalid (url + date)
|
||||
x integrate new locomotivecms home
|
@ -34,8 +34,72 @@ module Locomotive
|
||||
end
|
||||
end
|
||||
|
||||
# FIXME (Did): allows to pass attributes to the I18n translation key
|
||||
def inline_hints_for(method, options) #:nodoc:
|
||||
options[:hint] = localized_string(method, options[:hint], :hint, options[:hint_options] || {})
|
||||
return if options[:hint].blank? or options[:hint].kind_of? Hash
|
||||
hint_class = options[:hint_class] || default_hint_class
|
||||
template.content_tag(:p, Formtastic::Util.html_safe(options[:hint]), :class => hint_class)
|
||||
end
|
||||
|
||||
def model_name
|
||||
@object.present? ? (@object.class.name || @object.class.model_name) : @object_name.to_s.classify
|
||||
@object.present? ? (@object.class.model_name || @object.class.name) : @object_name.to_s.classify
|
||||
end
|
||||
|
||||
def normalize_model_name(name)
|
||||
if name =~ /(.+)\[(.+)\]/
|
||||
[$1, $2]
|
||||
else
|
||||
[name.split('/')].flatten
|
||||
end
|
||||
end
|
||||
|
||||
# FIXME (Did): why the hell should all the strings be escaped ?
|
||||
def localized_string(key, value, type, options = {}) #:nodoc:
|
||||
key = value if value.is_a?(::Symbol)
|
||||
|
||||
escaping = options.delete(:escaping) || false
|
||||
|
||||
if value.is_a?(::String)
|
||||
escaping ? escape_html_entities(value) : value
|
||||
else
|
||||
use_i18n = value.nil? ? i18n_lookups_by_default : (value != false)
|
||||
|
||||
if use_i18n
|
||||
model_name, nested_model_name = normalize_model_name(self.model_name.underscore)
|
||||
action_name = template.params[:action].to_s rescue ''
|
||||
attribute_name = key.to_s
|
||||
|
||||
defaults = ::Formtastic::I18n::SCOPES.reject do |i18n_scope|
|
||||
nested_model_name.nil? && i18n_scope.match(/nested_model/)
|
||||
end.collect do |i18n_scope|
|
||||
i18n_path = i18n_scope.dup
|
||||
i18n_path.gsub!('%{action}', action_name)
|
||||
i18n_path.gsub!('%{model}', model_name)
|
||||
i18n_path.gsub!('%{nested_model}', nested_model_name) unless nested_model_name.nil?
|
||||
i18n_path.gsub!('%{attribute}', attribute_name)
|
||||
i18n_path.gsub!('..', '.')
|
||||
i18n_path.to_sym
|
||||
end
|
||||
defaults << ''
|
||||
|
||||
defaults.uniq!
|
||||
|
||||
default_key = defaults.shift
|
||||
i18n_value = ::Formtastic::I18n.t(default_key,
|
||||
options.merge(:default => defaults, :scope => type.to_s.pluralize.to_sym))
|
||||
if i18n_value.blank? && type == :label
|
||||
# This is effectively what Rails label helper does for i18n lookup
|
||||
options[:scope] = [:helpers, type]
|
||||
options[:default] = defaults
|
||||
i18n_value = ::I18n.t(default_key, options)
|
||||
end
|
||||
if i18n_value.is_a?(::String)
|
||||
i18n_value = escaping ? escape_html_entities(i18n_value) : i18n_value
|
||||
end
|
||||
i18n_value.blank? ? nil : i18n_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user