Remove unnecessary includes, finish renaming set_header_data, only run set_header_data on html requests
This commit is contained in:
parent
f2cc51dd0d
commit
e6836c46a7
4 changed files with 7 additions and 20 deletions
|
|
@ -23,10 +23,10 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def set_header_data
|
||||
if user_signed_in?
|
||||
if user_signed_in? && request.format.html?
|
||||
@aspect = nil
|
||||
@object_aspect_ids = []
|
||||
@all_aspects = current_user.aspects.includes(:aspect_memberships)
|
||||
@all_aspects = current_user.aspects
|
||||
@notification_count = Notification.for(current_user, :unread =>true).count
|
||||
@unread_message_count = ConversationVisibility.sum(:unread, :conditions => "person_id = #{current_user.person.id}")
|
||||
end
|
||||
|
|
@ -98,18 +98,4 @@ class ApplicationController < ActionController::Base
|
|||
def grammatical_gender
|
||||
@grammatical_gender || nil
|
||||
end
|
||||
|
||||
def similar_people contact, opts={}
|
||||
opts[:limit] ||= 5
|
||||
aspect_ids = contact.aspect_ids
|
||||
count = Contact.count(:user_id => current_user.id,
|
||||
:person_id.ne => contact.person.id,
|
||||
:aspect_ids.in => aspect_ids)
|
||||
|
||||
if count > opts[:limit]
|
||||
offset = rand(count-opts[:limit])
|
||||
else
|
||||
offset = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class ContactsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
|
||||
def new
|
||||
@person = Person.find(params[:person_id])
|
||||
@aspects_with_person = []
|
||||
|
|
@ -40,6 +40,7 @@ class ContactsController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@all_aspects ||= current_user.aspects
|
||||
@contact = Contact.unscoped.where(:id => params[:id], :user_id => current_user.id).first
|
||||
|
||||
@person = @contact.person
|
||||
|
|
@ -61,7 +62,7 @@ class ContactsController < ApplicationController
|
|||
else
|
||||
flash[:error] = I18n.t('contacts.destroy.failure', :name => contact.person.name)
|
||||
end
|
||||
redirect_to contact.person
|
||||
redirect_to contact.person
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class PostsController < ApplicationController
|
||||
skip_before_filter :set_contacts_notifications_unread_count_and_status
|
||||
skip_before_filter :set_header_data
|
||||
skip_before_filter :count_requests
|
||||
skip_before_filter :set_invites
|
||||
skip_before_filter :set_locale
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class PublicsController < ApplicationController
|
|||
require File.join(Rails.root, '/lib/diaspora/parser')
|
||||
include Diaspora::Parser
|
||||
|
||||
skip_before_filter :set_contacts_notifications_unread_count_and_status, :except => [:create, :update]
|
||||
skip_before_filter :set_header_data
|
||||
skip_before_filter :count_requests
|
||||
skip_before_filter :set_invites
|
||||
skip_before_filter :set_locale
|
||||
|
|
|
|||
Loading…
Reference in a new issue