Loading app/assets/templates/profile_header_tpl.jst.hbs +65 −69 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ {{/if}} </h2> {{#if loggedIn}} {{#if has_tags}} <div class="description"> <i class="entypo tag"></i> Loading @@ -36,10 +35,8 @@ </div> {{/if}} {{/if}} {{/if}} </div> {{#if loggedIn}} <div id="profile_horizontal_bar"> {{#if show_profile_btns}} <div id="profile_buttons" class="pull-right"> Loading Loading @@ -101,4 +98,3 @@ {{/if}} </div> </div> {{/if}} app/controllers/people_controller.rb +2 −10 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class PeopleController < ApplicationController end gon.preloads[:person] = @person_json gon.preloads[:photos] = { count: photos_from(@person, :all).count(:all) count: Photo.visible(current_user, @person).count(:all) } gon.preloads[:contacts] = { count: Contact.contact_contacts_for(current_user, @person).count(:all), Loading Loading @@ -146,7 +146,7 @@ class PeopleController < ApplicationController @contacts_of_contact = Contact.contact_contacts_for(current_user, @person) gon.preloads[:person] = PersonPresenter.new(@person, current_user).full_hash_with_profile gon.preloads[:photos] = { count: photos_from(@person, :all).count(:all) count: Photo.visible(current_user, @person).count(:all) } gon.preloads[:contacts] = { count: @contacts_of_contact.count(:all), Loading Loading @@ -224,14 +224,6 @@ class PeopleController < ApplicationController @person.try(:remote?) && !user_signed_in? end def photos_from(person, limit) @photos ||= if user_signed_in? current_user.photos_from(person, limit: limit) else Photo.where(author_id: person.id, public: true) end.order('created_at desc') end def mark_corresponding_notifications_read Notification.where(recipient_id: current_user.id, target_type: "Person", target_id: @person.id, unread: true).each do |n| n.set_read_state( true ) Loading app/controllers/photos_controller.rb +5 −4 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # the COPYRIGHT file. class PhotosController < ApplicationController before_action :authenticate_user!, :except => :show before_action :authenticate_user!, except: %i(show index) respond_to :html, :json def show Loading @@ -19,15 +19,16 @@ class PhotosController < ApplicationController def index @post_type = :photos @person = Person.find_by_guid(params[:person_id]) authenticate_user! if @person.try(:remote?) && !user_signed_in? if @person @contact = current_user.contact_for(@person) @posts = current_user.photos_from(@person, max_time: max_time).order('created_at desc') @contact = current_user.contact_for(@person) if user_signed_in? @posts = Photo.visible(current_user, @person, :all, max_time) respond_to do |format| format.all do gon.preloads[:person] = PersonPresenter.new(@person, current_user).full_hash_with_profile gon.preloads[:photos] = { count: current_user.photos_from(@person, limit: :all).count(:all) count: Photo.visible(current_user, @person).count(:all) } gon.preloads[:contacts] = { count: Contact.contact_contacts_for(current_user, @person).count(:all), Loading app/models/photo.rb +9 −0 Original line number Diff line number Diff line Loading @@ -145,4 +145,13 @@ class Photo < ActiveRecord::Base def mutable? true end def self.visible(current_user, person, limit=:all, max_time=nil) photos = if current_user current_user.photos_from(person, limit: limit, max_time: max_time) else Photo.where(author_id: person.id, public: true) end photos.order("created_at desc") end end spec/controllers/people_controller_spec.rb +0 −13 Original line number Diff line number Diff line Loading @@ -205,19 +205,6 @@ describe PeopleController, :type => :controller do expect(response.body).not_to include(profile.first_name) end it "doesn't leak photos in the sidebar" do private_photo = @user.post(:photo, user_file: uploaded_photo, to: @aspect.id, public: false) public_photo = @user.post(:photo, user_file: uploaded_photo, to: @aspect.id, public: true) allow(@user.person).to receive(:remote?) { false } sign_out :user get :show, id: @user.person.to_param expect(response).to be_success expect(assigns(:photos)).not_to include private_photo expect(assigns(:photos)).to include public_photo end it "displays the correct number of photos" do 16.times do |i| eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true) Loading Loading
app/assets/templates/profile_header_tpl.jst.hbs +65 −69 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ {{/if}} </h2> {{#if loggedIn}} {{#if has_tags}} <div class="description"> <i class="entypo tag"></i> Loading @@ -36,10 +35,8 @@ </div> {{/if}} {{/if}} {{/if}} </div> {{#if loggedIn}} <div id="profile_horizontal_bar"> {{#if show_profile_btns}} <div id="profile_buttons" class="pull-right"> Loading Loading @@ -101,4 +98,3 @@ {{/if}} </div> </div> {{/if}}
app/controllers/people_controller.rb +2 −10 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class PeopleController < ApplicationController end gon.preloads[:person] = @person_json gon.preloads[:photos] = { count: photos_from(@person, :all).count(:all) count: Photo.visible(current_user, @person).count(:all) } gon.preloads[:contacts] = { count: Contact.contact_contacts_for(current_user, @person).count(:all), Loading Loading @@ -146,7 +146,7 @@ class PeopleController < ApplicationController @contacts_of_contact = Contact.contact_contacts_for(current_user, @person) gon.preloads[:person] = PersonPresenter.new(@person, current_user).full_hash_with_profile gon.preloads[:photos] = { count: photos_from(@person, :all).count(:all) count: Photo.visible(current_user, @person).count(:all) } gon.preloads[:contacts] = { count: @contacts_of_contact.count(:all), Loading Loading @@ -224,14 +224,6 @@ class PeopleController < ApplicationController @person.try(:remote?) && !user_signed_in? end def photos_from(person, limit) @photos ||= if user_signed_in? current_user.photos_from(person, limit: limit) else Photo.where(author_id: person.id, public: true) end.order('created_at desc') end def mark_corresponding_notifications_read Notification.where(recipient_id: current_user.id, target_type: "Person", target_id: @person.id, unread: true).each do |n| n.set_read_state( true ) Loading
app/controllers/photos_controller.rb +5 −4 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ # the COPYRIGHT file. class PhotosController < ApplicationController before_action :authenticate_user!, :except => :show before_action :authenticate_user!, except: %i(show index) respond_to :html, :json def show Loading @@ -19,15 +19,16 @@ class PhotosController < ApplicationController def index @post_type = :photos @person = Person.find_by_guid(params[:person_id]) authenticate_user! if @person.try(:remote?) && !user_signed_in? if @person @contact = current_user.contact_for(@person) @posts = current_user.photos_from(@person, max_time: max_time).order('created_at desc') @contact = current_user.contact_for(@person) if user_signed_in? @posts = Photo.visible(current_user, @person, :all, max_time) respond_to do |format| format.all do gon.preloads[:person] = PersonPresenter.new(@person, current_user).full_hash_with_profile gon.preloads[:photos] = { count: current_user.photos_from(@person, limit: :all).count(:all) count: Photo.visible(current_user, @person).count(:all) } gon.preloads[:contacts] = { count: Contact.contact_contacts_for(current_user, @person).count(:all), Loading
app/models/photo.rb +9 −0 Original line number Diff line number Diff line Loading @@ -145,4 +145,13 @@ class Photo < ActiveRecord::Base def mutable? true end def self.visible(current_user, person, limit=:all, max_time=nil) photos = if current_user current_user.photos_from(person, limit: limit, max_time: max_time) else Photo.where(author_id: person.id, public: true) end photos.order("created_at desc") end end
spec/controllers/people_controller_spec.rb +0 −13 Original line number Diff line number Diff line Loading @@ -205,19 +205,6 @@ describe PeopleController, :type => :controller do expect(response.body).not_to include(profile.first_name) end it "doesn't leak photos in the sidebar" do private_photo = @user.post(:photo, user_file: uploaded_photo, to: @aspect.id, public: false) public_photo = @user.post(:photo, user_file: uploaded_photo, to: @aspect.id, public: true) allow(@user.person).to receive(:remote?) { false } sign_out :user get :show, id: @user.person.to_param expect(response).to be_success expect(assigns(:photos)).not_to include private_photo expect(assigns(:photos)).to include public_photo end it "displays the correct number of photos" do 16.times do |i| eve.post(:photo, :user_file => uploaded_photo, :to => eve.aspects.first.id, :public => true) Loading