Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
4964771865
7 changed files with 22 additions and 14 deletions
|
|
@ -30,19 +30,11 @@ class Person
|
|||
|
||||
before_destroy :remove_all_traces
|
||||
before_validation :clean_url
|
||||
after_create :ensure_diaspora_handle
|
||||
validates_presence_of :url, :profile, :serialized_key
|
||||
validates_format_of :url, :with =>
|
||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
|
||||
|
||||
def ensure_diaspora_handle
|
||||
if self.owner?
|
||||
self.diaspora_handle = self.owner.diaspora_handle
|
||||
self.save
|
||||
end
|
||||
end
|
||||
|
||||
def self.search(query)
|
||||
Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) ||
|
||||
this.profile.first_name.match(/^#{query}/i) ||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ class User
|
|||
key :pending_request_ids, Array
|
||||
key :visible_post_ids, Array
|
||||
key :visible_person_ids, Array
|
||||
|
||||
|
||||
key :url, String
|
||||
|
||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||
|
||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||
|
|
@ -32,7 +34,11 @@ class User
|
|||
|
||||
many :aspects, :class_name => 'Aspect'
|
||||
|
||||
before_validation_on_create :setup_person
|
||||
|
||||
after_create :setup_person
|
||||
after_create :seed_aspects
|
||||
|
||||
|
||||
before_validation :do_bad_things
|
||||
before_save :downcase_username
|
||||
|
||||
|
|
@ -286,9 +292,13 @@ class User
|
|||
def self.instantiate!( opts = {} )
|
||||
opts[:person][:diaspora_handle] = opts[:email]
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create!( opts)
|
||||
User.create!(opts)
|
||||
end
|
||||
|
||||
|
||||
def self.create(opts ={})
|
||||
puts opts.inspect
|
||||
end
|
||||
|
||||
def terse_url
|
||||
terse = self.url.gsub(/(https?:|www\.)\/\//, '')
|
||||
terse = terse.chop! if terse[-1, 1] == '/'
|
||||
|
|
@ -305,7 +315,7 @@ class User
|
|||
|
||||
def setup_person
|
||||
self.person.serialized_key ||= User.generate_key.export
|
||||
#self.person.diaspora_handle ||= self.diaspora_handle
|
||||
self.person.diaspora_handle ||= self.diaspora_handle
|
||||
self.person.save!
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
||||
= devise_error_messages!
|
||||
= f.hidden_field :url, :value => request.host
|
||||
%p
|
||||
= f.label :username
|
||||
= f.text_field :username
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ def create
|
|||
user = User.create( :email => "#{username}@#{username}.joindiaspora.com",
|
||||
:username => username,
|
||||
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||
:url=> "http://#{username}.joindiaspora.com/",
|
||||
:person => Person.new(
|
||||
:diaspora_handle => "#{username}@#{username}.joindiaspora.com",
|
||||
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ url = "http://#{host}/"
|
|||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
:password => "evankorth",
|
||||
:url=> "http://#{username}.joindiaspora.com/"
|
||||
:person => Person.new(
|
||||
:diaspora_handle => "tom@tom.joindiaspora.com",
|
||||
:url => url,
|
||||
|
|
@ -21,6 +22,7 @@ user.person.save!
|
|||
|
||||
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
||||
:username => "korth",
|
||||
:url=> "http://#{username}.joindiaspora.com/"
|
||||
:password => "evankorth",
|
||||
:person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com",
|
||||
:url => url,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ remote_url = "http://tom.joindiaspora.com/"
|
|||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
:password => "evankorth",
|
||||
:url=> "http://#{username}.joindiaspora.com/"
|
||||
:person => {
|
||||
:diaspora_handle => "tom@tom.joindiaspora.com",
|
||||
:url => remote_url,
|
||||
|
|
@ -22,6 +23,7 @@ user.person.save!
|
|||
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
||||
:password => "evankorth",
|
||||
:username => "korth",
|
||||
:url=> "http://#{username}.joindiaspora.com/"
|
||||
:person => { :diaspora_handle => "korth@tom.joindiaspora.com",
|
||||
:url => remote_url,
|
||||
:profile => { :first_name => "Evan",
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ describe Request do
|
|||
xml = request.to_xml.to_s
|
||||
|
||||
xml.include?(@user.person.diaspora_handle).should be true
|
||||
xml.include?(@user.url).should be true
|
||||
xml.include?(@user.person.url).should be true
|
||||
xml.include?(@user.profile.first_name).should be true
|
||||
xml.include?(@user.profile.last_name).should be true
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue