aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 4853d633c..7bb5118ac 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -23,7 +23,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.97 2009-07-03 11:43:37 francis Exp $
+# $Id: user.rb,v 1.98 2009-08-05 16:31:11 francis Exp $
require 'digest/sha1'
@@ -42,6 +42,7 @@ class User < ActiveRecord::Base
has_many :post_redirects
has_many :track_things, :foreign_key => 'tracking_user_id', :order => 'created_at desc'
has_many :comments, :order => 'created_at desc'
+ has_one :profile_photo
attr_accessor :password_confirmation, :no_xapian_reindex
validates_confirmation_of :password, :message =>"^Please enter the same password twice"
@@ -254,6 +255,16 @@ class User < ActiveRecord::Base
return PublicBody.extract_domain_from_email(self.email)
end
+ def set_profile_photo(new_profile_photo)
+ ActiveRecord::Base.transaction do
+ if !self.profile_photo.nil?
+ self.profile_photo.destroy
+ end
+ new_profile_photo.user = self
+ self.profile_photo = new_profile_photo
+ end
+ end
+
private
def self.encrypted_password(password, salt)