Commit a96ba9e6ed89be70d91d72f627566957562ca7b0

Authored by Daniela Feitosa
1 parent d1609c73

access_level: optimizing the search for members

- Also fixed db/schema
(ActionItem2852)
app/controllers/my_profile/cms_controller.rb
@@ -75,11 +75,10 @@ class CmsController < MyProfileController @@ -75,11 +75,10 @@ class CmsController < MyProfileController
75 @article.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} unless params[:q].nil? 75 @article.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} unless params[:q].nil?
76 76
77 @tokenized_children = prepare_to_token_input( 77 @tokenized_children = prepare_to_token_input(
78 - profile.members.map{|m|  
79 - m if @article.article_privacy_exceptions.include?(m)  
80 - }.compact 78 + profile.members.includes(:articles_with_access).find_all{ |m|
  79 + m.articles_with_access.include?(@article)
  80 + }
81 ) 81 )
82 -  
83 refuse_blocks 82 refuse_blocks
84 record_coming 83 record_coming
85 if request.post? 84 if request.post?
app/helpers/article_helper.rb
@@ -57,7 +57,7 @@ module ArticleHelper @@ -57,7 +57,7 @@ module ArticleHelper
57 radio_button(:article, :published, false) + 57 radio_button(:article, :published, false) +
58 content_tag('label', _('Private'), :for => 'article_published_false', :id => "label_private") 58 content_tag('label', _('Private'), :for => 'article_published_false', :id => "label_private")
59 ) + 59 ) +
60 - (article.profile.class == Community ? content_tag('div', 60 + (article.profile.community? ? content_tag('div',
61 content_tag('label', _('Fill in the search field to add the exception users to see this content'), :id => "text-input-search-exception-users") + 61 content_tag('label', _('Fill in the search field to add the exception users to see this content'), :id => "text-input-search-exception-users") +
62 token_input_field_tag(:q, 'search-article-privacy-exceptions', {:action => 'search_article_privacy_exceptions'}, 62 token_input_field_tag(:q, 'search-article-privacy-exceptions', {:action => 'search_article_privacy_exceptions'},
63 {:focus => false, :hint_text => _('Type in a search term for a user'), :pre_populate => tokenized_children})) : 63 {:focus => false, :hint_text => _('Type in a search term for a user'), :pre_populate => tokenized_children})) :
@@ -465,7 +465,6 @@ ActiveRecord::Schema.define(:version => 20140108132730) do @@ -465,7 +465,6 @@ ActiveRecord::Schema.define(:version => 20140108132730) do
465 t.boolean "is_template", :default => false 465 t.boolean "is_template", :default => false
466 t.integer "template_id" 466 t.integer "template_id"
467 t.string "redirection_after_login" 467 t.string "redirection_after_login"
468 - t.text "settings"  
469 end 468 end
470 469
471 add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id" 470 add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id"