MS factored out User.first EVERYWHERE. Use User.owner now instead (currently just calls User.first, but now it is easier to make a new change

This commit is contained in:
maxwell 2010-07-10 10:34:46 -07:00
parent a02a833625
commit 902a8cb349
10 changed files with 33 additions and 27 deletions

View file

@ -17,21 +17,21 @@ class DashboardsController < ApplicationController
def warzombie
render :nothing => true
if User.first.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.first)
Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.first )
StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.first, :created_at => Time.now-930)
StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => User.first, :created_at => Time.now-43990)
StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => User.first, :created_at => Time.now-4390)
Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => User.first, :created_at => Time.now-54390)
Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "<p>The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.</p> <p>also i can tell it wont be long and also happy summer imaginary constructs -mumblelard</p>", :person => User.first, :created_at => Time.now-3090)
StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => User.first, :created_at => Time.now-30900)
Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => User.first, :created_at => Time.now-9090)
StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => User.first, :created_at => Time.now-590000)
StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => User.first, :created_at => Time.now-503900)
StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => User.first, :created_at => Time.now-4400)
StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => User.first, :created_at => Time.now-400239)
StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.first, :created_at => Time.now-150000)
if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.owner)
Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.owner )
StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.owner, :created_at => Time.now-930)
StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => User.owner, :created_at => Time.now-43990)
StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => User.owner, :created_at => Time.now-4390)
Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => User.owner, :created_at => Time.now-54390)
Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "<p>The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.</p> <p>also i can tell it wont be long and also happy summer imaginary constructs -mumblelard</p>", :person => User.owner, :created_at => Time.now-3090)
StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => User.owner, :created_at => Time.now-30900)
Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => User.owner, :created_at => Time.now-9090)
StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => User.owner, :created_at => Time.now-590000)
StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => User.owner, :created_at => Time.now-503900)
StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => User.owner, :created_at => Time.now-4400)
StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => User.owner, :created_at => Time.now-400239)
StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.owner, :created_at => Time.now-150000)
end
end
end

View file

@ -10,7 +10,7 @@ module ApplicationHelper
end
def mine?(post)
post.person == User.first
post.person == User.owner
end
def type_partial(post)
@ -39,9 +39,9 @@ module ApplicationHelper
def owner_picture
default = "/images/user/default.jpg"
image = "/images/user/#{User.first.profile.last_name.gsub(/ /,'').downcase}.jpg"
image = "/images/user/#{User.owner.profile.last_name.gsub(/ /,'').downcase}.jpg"
if File.exist?("public/images/user/#{User.first.profile.last_name.gsub(/ /,'').downcase}.jpg")
if File.exist?("public/images/user/#{User.owner.profile.last_name.gsub(/ /,'').downcase}.jpg")
image_tag image, :id => "user_picture"
else
image_tag default, :id => "user_picture"

View file

@ -29,7 +29,7 @@ class Comment
protected
def send_people_comments_on_my_posts
if User.first.mine?(self.post) && !(self.person.is_a? User)
if User.owner.mine?(self.post) && !(self.person.is_a? User)
self.push_to(self.post.people_with_permissions)
end
end

View file

@ -29,6 +29,7 @@ class Person
scope :friends, where(:_type => "Person", :active => true)
def real_name
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
end

View file

@ -36,7 +36,7 @@ class Post
end
def self.my_newest
self.newest(User.first)
self.newest(User.owner)
end
def self.newest_by_email(email)
self.newest(Person.first(:email => email))

View file

@ -10,6 +10,8 @@ class User < Person
before_validation :do_bad_things
######## Commenting ########
def comment(text, options = {})
raise "must comment on something!" unless options[:on]
@ -80,6 +82,9 @@ class User < Person
self.password_confirmation = self.password
end
def self.owner
User.first
end
protected

View file

@ -6,7 +6,7 @@
/= f.check_box :remember_me
/= f.label :remember_me
= hidden_field_tag "user_email", "#{User.first.email}", :name => "user[email]"
= hidden_field_tag "user_email", "#{User.owner.email}", :name => "user[email]"
= f.submit "Sign in"
/= render :partial => "devise/shared/links"

View file

@ -39,11 +39,11 @@
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_#{name}"
- if User.first
- if User.owner
%div#huge_text
welcome back,
%span
= User.first.real_name.downcase
= User.owner.real_name.downcase
= yield
-else
%div#huge_text

View file

@ -33,7 +33,7 @@ module Diaspora
if p.is_a? Retraction
p.perform
elsif p.is_a? Request
User.first.receive_friend_request(p)
User.owner.receive_friend_request(p)
#This line checks if the sender was in the database, among other things?
elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) #WTF
p.save
@ -51,7 +51,7 @@ module Diaspora
@@queue = MessageHandler.new
def notify_people
if self.person_id == User.first.id
if self.person_id == User.owner.id
push_to(people_with_permissions)
end
end

View file

@ -12,7 +12,7 @@ describe Post do
end
it "should associate the owner if none is present" do
@post.person.should == User.first
@post.person.should == User.owner
end
end