Correct date writing for consent_date

pull/6341/head
Oliver Günther 7 years ago
parent e208a1e437
commit 9efba5d532
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 2
      app/assets/javascripts/settings.js.erb
  2. 19
      app/models/setting.rb
  3. 2
      app/views/settings/_users.html.erb

@ -65,7 +65,7 @@ See doc/COPYRIGHT.rdoc for more details.
});
/* Javascript for user settings consent date */
$("#consent-date").datepicker();
$("#settings_consent_date").datepicker();
});
/** Toggle notification settings fields */

@ -136,11 +136,24 @@ class Setting < ActiveRecord::Base
end
def value=(v)
if v && @@available_settings[name] && @@available_settings[name]['serialized']
v = v.to_yaml
write_attribute(:value, formatted_value(v))
end
write_attribute(:value, v.to_s)
def formatted_value(value)
return value unless value.present?
default = @@available_settings[name]
if default['serialized']
return value.to_yaml
end
case default['format']
when "datetime"
value.iso8601
else
value.to_s
end
end
# Returns the value of the setting named name

@ -49,7 +49,7 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="form--field">
<%= setting_block("consent_date") do %>
<span class="form--text-field-container -slim">
<input type="text" id="consent-date">
<input type="text" name="settings[consent_date]" id="settings_consent_date">
</span>
<% end %>
<div class="form--field-instructions">

Loading…
Cancel
Save