aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorfrancis <francis>2009-08-05 16:31:10 +0000
committerfrancis <francis>2009-08-05 16:31:10 +0000
commit0610eeb4597138723cce97dcd0c4702a0de0dbcd (patch)
tree73c3c36b700911f41ac5b2be08aee36efd99085b /app/models/user.rb
parent9d3f7b1d205e36768e0910d4748ee913cb8df60f (diff)
Some (as yet unused) profile photo code done on a whim on the train while it
was my birthday.
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)