minimizing some queries in the views. only select aspect names and ids in application controller.
This commit is contained in:
parent
d5d4a08f03
commit
a932547d12
13 changed files with 35 additions and 38 deletions
|
|
@ -14,14 +14,9 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def set_contacts_and_status
|
def set_contacts_and_status
|
||||||
if current_user
|
if current_user
|
||||||
if params[:aspect] == nil || params[:aspect] == 'all'
|
@aspect = nil
|
||||||
@aspect = :all
|
@aspects = current_user.aspects.fields(:name)
|
||||||
else
|
@aspects_dropdown_array = @aspects.collect{|x| [x.to_s, x.id]}
|
||||||
@aspect = current_user.aspect_by_id( params[:aspect])
|
|
||||||
end
|
|
||||||
|
|
||||||
@aspects = current_user.aspects
|
|
||||||
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
|
|
||||||
@contacts = current_user.contacts
|
@contacts = current_user.contacts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -37,7 +32,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_requests
|
def count_requests
|
||||||
@request_count = current_user.requests_for_me.size if current_user
|
@request_count = current_user.requests_for_me.count if current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_invites
|
def set_invites
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,11 @@ class AspectsController < ApplicationController
|
||||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||||
else
|
else
|
||||||
@aspect_contacts = @aspect.contacts
|
@aspect_contacts = @aspect.contacts
|
||||||
|
@aspect_contacts_count = @aspect_contacts.count
|
||||||
|
|
||||||
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15
|
@posts = @aspect.posts.find_all_by__type("StatusMessage", :order => 'created_at desc').paginate :page => params[:page], :per_page => 15
|
||||||
|
@posts_count = @posts.count
|
||||||
|
|
||||||
respond_with @aspect
|
respond_with @aspect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_aspect?(aspect)
|
def current_aspect?(aspect)
|
||||||
!@aspect.is_a?(Symbol) && @aspect.id == aspect.id
|
!@aspect.nil? && !@aspect.is_a?(Symbol) && @aspect.id == aspect.id
|
||||||
end
|
end
|
||||||
|
|
||||||
def aspect_or_all_path aspect
|
def aspect_or_all_path aspect
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#edit_aspect_pane
|
#edit_aspect_pane
|
||||||
- if @contacts.count > 0
|
- if @contacts.count > 0
|
||||||
%h4= t('.add_existing')
|
%h4= t('.add_existing')
|
||||||
= render 'shared/contact_list', :aspect => aspect, :contacts => contacts, :manage => defined?(manage)
|
= render 'shared/contact_list', :aspect_id => aspect.id, :contacts => contacts, :manage => defined?(manage)
|
||||||
|
|
||||||
= render 'shared/add_contact', :aspect => aspect
|
= render 'shared/add_contact', :aspect_id => aspect.id
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
.big_buttons
|
.big_buttons
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,5 @@
|
||||||
|
|
||||||
.fancybox_content
|
.fancybox_content
|
||||||
%div{:id => "manage_aspect_contacts_pane_#{aspect.id}"}
|
%div{:id => "manage_aspect_contacts_pane_#{aspect.id}"}
|
||||||
= render "requests/manage_aspect_contacts", :aspect => aspect, :manage => true
|
= render "requests/manage_aspect_contacts", :aspect_name => aspect.name, :aspect_id => aspect.id, :manage => true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,18 @@
|
||||||
= @aspect
|
= @aspect
|
||||||
|
|
||||||
%span.aspect_contact_count{:style=>"color:#999;font-size:14px;"}
|
%span.aspect_contact_count{:style=>"color:#999;font-size:14px;"}
|
||||||
= t('contacts', :count=>@aspect_contacts.count)
|
= t('contacts', :count=>@aspect_contacts_count)
|
||||||
= link_to t('.edit_aspect'), "#", :id => "edit_aspect_trigger"
|
= link_to t('.edit_aspect'), "#", :id => "edit_aspect_trigger"
|
||||||
|
|
||||||
.span-8.append-1
|
.span-8.append-1
|
||||||
= render 'shared/aspect_contacts', :contacts => @aspect_contacts, :aspect => @aspect
|
= render 'shared/aspect_contacts', :contacts => @aspect_contacts, :aspect => @aspect
|
||||||
|
= render 'aspects/edit_aspect_pane', :contacts => @contacts, :aspect => @aspect
|
||||||
|
|
||||||
|
|
||||||
.span-15.last
|
.span-15.last
|
||||||
= render 'shared/publisher', :aspect => @aspect
|
= render 'shared/publisher', :aspect => @aspect
|
||||||
= render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @aspect_contacts.count, :options => false
|
= render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @aspect_contacts_count, :options => false
|
||||||
= render 'aspects/no_posts_message', :post_count => @posts.count, :contact_count=> @aspect_contacts.count
|
= render 'aspects/no_posts_message', :post_count => @posts_count, :contact_count=> @aspect_contacts_count
|
||||||
|
|
||||||
= render 'shared/stream', :posts => @posts
|
= render 'shared/stream', :posts => @posts
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
%ul.comments{:id => post.id, :class => ("hidden" if defined?(hidden) && hidden)}
|
%ul.comments{:id => post_id, :class => ("hidden" if defined?(hidden) && hidden)}
|
||||||
- for comment in post.comments
|
- for comment in comments
|
||||||
= render 'comments/comment', :comment => comment, :person => comment.person
|
= render 'comments/comment', :comment => comment, :person => comment.person
|
||||||
%li.comment.show
|
%li.comment.show
|
||||||
= render 'comments/new_comment', :post => post
|
= render 'comments/new_comment', :post_id => post_id
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
= form_for Comment.new, :html => {:id => "new_comment_on_#{post.id}" }, :remote => true do |comment|
|
= form_for Comment.new, :html => {:id => "new_comment_on_#{post_id}" }, :remote => true do |comment|
|
||||||
%p
|
%p
|
||||||
= label_tag "comment_text_on_#{post.id}", t('.comment')
|
= label_tag "comment_text_on_#{post_id}", t('.comment')
|
||||||
= comment.text_area :text, :rows => 1, :id => "comment_text_on_#{post.id}", :class => "comment_box"
|
= comment.text_area :text, :rows => 1, :id => "comment_text_on_#{post_id}", :class => "comment_box"
|
||||||
= comment.hidden_field :post_id, :id => "post_id_on_#{post.id}", :value => post.id
|
= comment.hidden_field :post_id, :id => "post_id_on_#{post_id}", :value => post_id
|
||||||
= comment.submit t('.comment'), :id => "comment_submit_#{post.id}", :class => "comment_submit button", :disable_with => t('.commenting')
|
= comment.submit t('.comment'), :id => "comment_submit_#{post_id}", :class => "comment_submit button", :disable_with => t('.commenting')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
.modal_title_bar
|
.modal_title_bar
|
||||||
%h4
|
%h4
|
||||||
= t('.manage_within')
|
= t('.manage_within')
|
||||||
%i= aspect.name
|
%i= aspect_name
|
||||||
.span-6.append-1.last
|
.span-6.append-1.last
|
||||||
%h3= t('.existing')
|
%h3= t('.existing')
|
||||||
= render 'shared/contact_list', :aspect => aspect, :contacts => @contacts, :manage => defined?(manage)
|
= render 'shared/contact_list', :aspect_id => aspect_id, :contacts => @contacts, :manage => defined?(manage)
|
||||||
|
|
||||||
.span-7.last
|
.span-7.last
|
||||||
= render 'shared/add_contact', :aspect => aspect
|
= render 'shared/add_contact', :aspect_id => aspect_id
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
= t('aspects.manage.add_a_new_contact')
|
= t('aspects.manage.add_a_new_contact')
|
||||||
= info_text(t('.enter_a_diaspora_username'))
|
= info_text(t('.enter_a_diaspora_username'))
|
||||||
|
|
||||||
= form_tag(person_by_handle_path, :id => "new_request_to_#{aspect.id}", :class => "webfinger_form", :remote => true) do
|
= form_tag(person_by_handle_path, :id => "new_request_to_#{aspect_id}", :class => "webfinger_form", :remote => true) do
|
||||||
= search_field_tag :diaspora_handle,'', :id => "request_d_handle_to_#{aspect.id}", :results => 5, :placeholder => t('.diaspora_handle')
|
= search_field_tag :diaspora_handle,'', :id => "request_d_handle_to_#{aspect_id}", :results => 5, :placeholder => t('.diaspora_handle')
|
||||||
= hidden_field_tag :aspect_id, aspect.id
|
= hidden_field_tag :aspect_id, aspect_id
|
||||||
= submit_tag t('.create_request')
|
= submit_tag t('.create_request')
|
||||||
|
|
||||||
%p{:style => "margin:12px 0 24px 0px;color:#999;text-align:center;"}
|
%p{:style => "margin:12px 0 24px 0px;color:#999;text-align:center;"}
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#loader.hidden
|
#loader.hidden
|
||||||
= image_tag 'ajax-loader.gif'
|
= image_tag 'ajax-loader.gif'
|
||||||
|
|
||||||
%ul#request_result{:aspect_id => aspect.id}
|
%ul#request_result{:aspect_id => aspect_id}
|
||||||
%li.error.hidden
|
%li.error.hidden
|
||||||
#message
|
#message
|
||||||
= link_to t('.know_email'), "#invite_user_pane", :class => "invite_user_button"
|
= link_to t('.know_email'), "#invite_user_pane", :class => "invite_user_button"
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
= link_to t('.add_aspect'), '#add_aspect_pane', :class => "add_aspect_button"
|
= link_to t('.add_aspect'), '#add_aspect_pane', :class => "add_aspect_button"
|
||||||
|
|
||||||
%ul
|
%ul
|
||||||
- for user_aspect in current_user.aspects
|
- for user_aspect in @aspects
|
||||||
%li
|
%li
|
||||||
%h4
|
%h4
|
||||||
= link_to user_aspect, user_aspect
|
= link_to user_aspect, user_aspect
|
||||||
|
|
@ -88,7 +88,3 @@
|
||||||
%h3= t('.invites')
|
%h3= t('.invites')
|
||||||
= render "shared/invitations", :invites => @invites
|
= render "shared/invitations", :invites => @invites
|
||||||
|
|
||||||
-else
|
|
||||||
= render 'aspects/edit_aspect_pane', :aspect => aspect, :contacts => @contacts
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,4 @@
|
||||||
%span.name
|
%span.name
|
||||||
= link_to contact.person.real_name, contact.person
|
= link_to contact.person.real_name, contact.person
|
||||||
.right
|
.right
|
||||||
= aspect_membership_button(aspect.id, contact)
|
= aspect_membership_button(aspect_id, contact)
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,5 @@
|
||||||
|
|
||||||
= comment_toggle(post.comments.count)
|
= comment_toggle(post.comments.count)
|
||||||
|
|
||||||
= render "comments/comments", :post => post, :hidden => (post.comments.count == 0)
|
= render "comments/comments", :post_id => post.id, :comments => post.comments, :hidden => (post.comments.count == 0)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue