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 75 @article.article_privacy_exceptions = params[:q].split(/,/).map{|n| environment.people.find n.to_i} unless params[:q].nil?
76 76  
77 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 82 refuse_blocks
84 83 record_coming
85 84 if request.post?
... ...
app/helpers/article_helper.rb
... ... @@ -57,7 +57,7 @@ module ArticleHelper
57 57 radio_button(:article, :published, false) +
58 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 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 62 token_input_field_tag(:q, 'search-article-privacy-exceptions', {:action => 'search_article_privacy_exceptions'},
63 63 {:focus => false, :hint_text => _('Type in a search term for a user'), :pre_populate => tokenized_children})) :
... ...
db/schema.rb
... ... @@ -465,7 +465,6 @@ ActiveRecord::Schema.define(:version => 20140108132730) do
465 465 t.boolean "is_template", :default => false
466 466 t.integer "template_id"
467 467 t.string "redirection_after_login"
468   - t.text "settings"
469 468 end
470 469  
471 470 add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id"
... ...