simplify closet hangers view, replace user_is?(@user) with !public_perspective?
This commit is contained in:
parent
e0c00cc8ed
commit
02ef70f749
5 changed files with 14 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
helper_method :can_use_image_mode?
|
helper_method :can_use_image_mode?, :user_is?
|
||||||
|
|
||||||
def authenticate_user! # too lazy to change references to login_path
|
def authenticate_user! # too lazy to change references to login_path
|
||||||
redirect_to(login_path) unless user_signed_in?
|
redirect_to(login_path) unless user_signed_in?
|
||||||
|
@ -18,5 +18,9 @@ class ApplicationController < ActionController::Base
|
||||||
def on_access_denied
|
def on_access_denied
|
||||||
render :file => 'public/403.html', :layout => false, :status => :forbidden
|
render :file => 'public/403.html', :layout => false, :status => :forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_is?(user)
|
||||||
|
user_signed_in? && user == current_user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ClosetHangersController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@user = User.find params[:user_id]
|
@user = User.find params[:user_id]
|
||||||
@closet_hangers = @user.closet_hangers.alphabetical_by_item_name.includes(:item)
|
@closet_hangers = @user.closet_hangers.alphabetical_by_item_name.includes(:item)
|
||||||
|
@public_perspective = params.has_key?(:public) || !user_is?(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Since the user does not care about the idea of a hanger, but rather the
|
# Since the user does not care about the idea of a hanger, but rather the
|
||||||
|
|
|
@ -101,9 +101,5 @@ module ApplicationHelper
|
||||||
def title(value)
|
def title(value)
|
||||||
content_for :title, value
|
content_for :title, value
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_is?(user)
|
|
||||||
user_signed_in? && user == current_user
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
module ClosetHangersHelper
|
module ClosetHangersHelper
|
||||||
|
def public_perspective?
|
||||||
|
@public_perspective
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
- if user_is?(@user)
|
- unless public_perspective?
|
||||||
- title 'Your Items'
|
- title 'Your Items'
|
||||||
- content_for :before_flashes do
|
- content_for :before_flashes do
|
||||||
= link_to "Import closet from Neopets", new_closet_page_path, :id => 'import-link'
|
= link_to "Import closet from Neopets", new_closet_page_path, :id => 'import-link'
|
||||||
|
@ -8,15 +8,15 @@
|
||||||
- else
|
- else
|
||||||
- title "#{@user.name}'s Items"
|
- title "#{@user.name}'s Items"
|
||||||
|
|
||||||
#closet-hangers{:class => user_is?(@user) ? 'current-user' : nil}
|
#closet-hangers{:class => public_perspective? ? nil : 'current-user'}
|
||||||
- if !@closet_hangers.empty?
|
- if !@closet_hangers.empty?
|
||||||
- if user_is?(@user)
|
- unless public_perspective?
|
||||||
%p
|
%p
|
||||||
These are the items you own. Hover over an item to remove it from the
|
These are the items you own. Hover over an item to remove it from the
|
||||||
list or to change the quantity.
|
list or to change the quantity.
|
||||||
= render :partial => 'closet_hanger', :collection => @closet_hangers, :locals => {:show_controls => user_is?(@user)}
|
= render :partial => 'closet_hanger', :collection => @closet_hangers, :locals => {:show_controls => user_is?(@user)}
|
||||||
- else
|
- else
|
||||||
- if user_is?(@user)
|
- unless public_perspective?
|
||||||
%p You haven't tracked any items on Dress to Impress.
|
%p You haven't tracked any items on Dress to Impress.
|
||||||
%p
|
%p
|
||||||
Here you can keep track of what items you already own, so that as you
|
Here you can keep track of what items you already own, so that as you
|
||||||
|
|
Loading…
Reference in a new issue