Skip to content
Extraits de code Groupes Projets
Valider fff43bf6 rédigé par danielvincent's avatar danielvincent
Parcourir les fichiers

profile defaults key searchable to true. search takes searchable into account.

parent a6d19066
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -55,6 +55,10 @@ class PeopleController < ApplicationController
params[:person][:profile][:birthday] ||= Date.parse("#{birthday[:year]}-#{birthday[:month]}-#{birthday[:day]}")
end
search_flag = params[:person][:searchable]
search_flag.to_s.match(/(true)/) ? search_flag = true : search_flag = false
params[:person][:searchable] = search_flag
# upload and set new profile photo
if params[:person][:profile][:image].present?
raw_image = params[:person][:profile].delete(:image)
......
......@@ -43,8 +43,10 @@ class Person
ensure_index :diaspora_handle
scope :searchable, where('profile.searchable' => true)
def self.search(query)
return Person.all if query.to_s.empty?
return Person.searchable.all if query.to_s.empty?
query_tokens = query.to_s.strip.split(" ")
full_query_text = Regexp.escape(query.to_s.strip)
......@@ -52,8 +54,8 @@ class Person
query_tokens.each do |token|
q = Regexp.escape(token.to_s.strip)
p = Person.all('profile.first_name' => /^#{q}/i) \
| Person.all('profile.last_name' => /^#{q}/i) \
p = Person.searchable.all('profile.first_name' => /^#{q}/i) \
| Person.searchable.all('profile.last_name' => /^#{q}/i) \
| p
end
......
......@@ -8,25 +8,27 @@ class Profile
include Diaspora::Webhooks
include ROXML
xml_reader :diaspora_handle
xml_reader :first_name
xml_reader :last_name
xml_reader :image_url
xml_reader :birthday
xml_reader :gender
xml_reader :bio
xml_accessor :diaspora_handle
xml_reader :searchable
key :diaspora_handle, String
key :first_name, String
key :last_name, String
key :image_url, String
key :birthday, Date
key :gender, String
key :bio, String
key :diaspora_handle, String
key :searchable, Boolean, :default => true
after_validation :strip_names
validates_length_of :first_name, :maximum => 32
validates_length_of :last_name, :maximum => 32
validates_length_of :last_name, :maximum => 32
before_save :strip_names
......
......@@ -44,6 +44,12 @@
= t('.your_photo')
= render 'people/profile_photo_upload', :form => profile
%h4
Search
%p{:class=>"checkbox_select"}
= profile.label :searchable, "Allow for people to search for you"
= profile.check_box :searchable, {:checked => @person.profile.searchable}, true, false
.submit_block
= link_to t('cancel'), edit_user_path(current_user)
= t('or')
......
......@@ -35,6 +35,12 @@
Your photo
= render 'people/profile_photo_upload', :form => profile
%h4
Search
%p{:class=>"checkbox_select"}
= profile.label :searchable, "Allow for people to search for you"
= profile.check_box :searchable, {:checked => @person.profile.searchable}, true, false
= hidden_field_tag :getting_started, @step
.submit_block
......
......@@ -652,6 +652,11 @@ form p
:padding 0
:margin 0
form p.checkbox_select
label
:left 20px
:top 0
label
:font
:family 'Arial', 'Helvetica', sans-serif
......@@ -1450,3 +1455,5 @@ ul.aspects
:padding
:left 120px
......@@ -187,6 +187,12 @@ describe Person do
people = Person.search("Casey Grippi")
people.should == [@friend_four]
end
it 'should only display searchable people' do
invisible_person = Factory(:person, :profile => {:searchable => false, :first_name => "johnson"})
Person.search("johnson").should_not include invisible_person
Person.search("").should_not include invisible_person
end
end
context 'people finders for webfinger' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter