X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/52be0e81a0d8fb30a635b32f85d4465fc0578067..b6163f0fc29740b4d9953a8c1fe47875ce2ecab0:/app/models/user.rb?ds=sidebyside diff --git a/app/models/user.rb b/app/models/user.rb index cc5389663..3b55040c6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -41,10 +41,15 @@ class User < ActiveRecord::Base validates_numericality_of :home_zoom, :only_integer => true, :allow_nil => true validates_inclusion_of :preferred_editor, :in => Editors::ALL_EDITORS, :allow_nil => true - after_initialize :set_creation_time + attr_accessible :display_name, :email, :email_confirmation, :openid_url, + :pass_crypt, :pass_crypt_confirmation, :consider_pd + + after_initialize :set_defaults before_save :encrypt_password - file_column :image, :magick => { :geometry => "100x100>" } + has_attached_file :image, + :default_url => "/assets/:class/:attachment/:style.png", + :styles => { :large => "100x100>", :small => "50x50>" } def self.authenticate(options) if options[:username] and options[:password] @@ -96,6 +101,10 @@ class User < ActiveRecord::Base return el1 end + def description + RichText.new(read_attribute(:description_format), read_attribute(:description)) + end + def languages attribute_present?(:languages) ? read_attribute(:languages).split(/ *, */) : [] end @@ -215,8 +224,9 @@ class User < ActiveRecord::Base private - def set_creation_time + def set_defaults self.creation_time = Time.now.getutc unless self.attribute_present?(:creation_time) + self.description_format = "markdown" unless self.attribute_present?(:description_format) end def encrypt_password