From d5641dddbba73dbc521d4262c121e98b0cab4e03 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 12 Jul 2011 20:03:04 -0400 Subject: [PATCH] user closet display --- app/controllers/closet_hangers_controller.rb | 7 +++++++ app/helpers/application_helper.rb | 4 ++++ app/helpers/closet_hangers_helper.rb | 2 ++ app/stylesheets/closet_hangers/index.sass | 4 ++++ app/stylesheets/screen.sass | 1 + .../closet_hangers/_closet_hanger.html.haml | 6 ++++++ app/views/closet_hangers/index.html.haml | 20 +++++++++++++++++++ app/views/items/_item.html.haml | 6 ++---- app/views/items/_item_link.html.haml | 5 +++++ config/routes.rb | 1 + .../compiled/closet_hangers/index.css | 4 ++++ public/stylesheets/compiled/screen.css | 5 +++++ .../closet_hangers_controller_spec.rb | 5 +++++ spec/helpers/closet_hangers_helper_spec.rb | 15 ++++++++++++++ 14 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 app/controllers/closet_hangers_controller.rb create mode 100644 app/helpers/closet_hangers_helper.rb create mode 100644 app/stylesheets/closet_hangers/index.sass create mode 100644 app/views/closet_hangers/_closet_hanger.html.haml create mode 100644 app/views/closet_hangers/index.html.haml create mode 100644 app/views/items/_item_link.html.haml create mode 100644 public/stylesheets/compiled/closet_hangers/index.css create mode 100644 spec/controllers/closet_hangers_controller_spec.rb create mode 100644 spec/helpers/closet_hangers_helper_spec.rb diff --git a/app/controllers/closet_hangers_controller.rb b/app/controllers/closet_hangers_controller.rb new file mode 100644 index 00000000..def5dfbe --- /dev/null +++ b/app/controllers/closet_hangers_controller.rb @@ -0,0 +1,7 @@ +class ClosetHangersController < ApplicationController + def index + @user = User.find params[:user_id] + @closet_hangers = @user.closet_hangers.alphabetical_by_item_name.includes(:item) + end +end + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f30b2a73..6c338888 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -97,5 +97,9 @@ module ApplicationHelper def title(value) content_for :title, value end + + def user_is?(user) + user_signed_in? && user == current_user + end end diff --git a/app/helpers/closet_hangers_helper.rb b/app/helpers/closet_hangers_helper.rb new file mode 100644 index 00000000..a6c002f7 --- /dev/null +++ b/app/helpers/closet_hangers_helper.rb @@ -0,0 +1,2 @@ +module ClosetHangersHelper +end diff --git a/app/stylesheets/closet_hangers/index.sass b/app/stylesheets/closet_hangers/index.sass new file mode 100644 index 00000000..ad242282 --- /dev/null +++ b/app/stylesheets/closet_hangers/index.sass @@ -0,0 +1,4 @@ +body.closet_hangers-index + #closet-hangers + text-align: center + diff --git a/app/stylesheets/screen.sass b/app/stylesheets/screen.sass index 2ae499f8..73b7ca23 100644 --- a/app/stylesheets/screen.sass +++ b/app/stylesheets/screen.sass @@ -6,6 +6,7 @@ @import partials/jquery.jgrowl +@import closet_hangers/index @import contributions/index @import items @import items/index diff --git a/app/views/closet_hangers/_closet_hanger.html.haml b/app/views/closet_hangers/_closet_hanger.html.haml new file mode 100644 index 00000000..fce078bb --- /dev/null +++ b/app/views/closet_hangers/_closet_hanger.html.haml @@ -0,0 +1,6 @@ +.object + = render :partial => 'items/item_link', :locals => {:item => closet_hanger.item} + %span.quantity + = surround '(', ')' do + = closet_hanger.quantity + diff --git a/app/views/closet_hangers/index.html.haml b/app/views/closet_hangers/index.html.haml new file mode 100644 index 00000000..1c30b833 --- /dev/null +++ b/app/views/closet_hangers/index.html.haml @@ -0,0 +1,20 @@ +- if user_is?(@user) + - title 'Your Closet' +- else + - title "#{@user.name}'s Closet" +#closet-hangers + - if !@closet_hangers.empty? + = render @closet_hangers + - else + - if user_is?(@user) + %p You don't have any items in your Dress to Impress closet. + %p + Your Dress to Impress closet is a way to keep track of what items you + have in your Neopets closet. Once you load your Neopets closet into + Dress to Impress, as you play with various outfit ideas you can keep + track of what items you already own. And, who knows? Maybe some day + you can use it as a up-for-trade list or wishlist. We'll see what + happens. + - else + %p #{@user.name} doesn't have any items in their Dress to Impress closet. + diff --git a/app/views/items/_item.html.haml b/app/views/items/_item.html.haml index 1634f0be..a3de7727 100644 --- a/app/views/items/_item.html.haml +++ b/app/views/items/_item.html.haml @@ -1,5 +1,3 @@ .object - = link_to item_path(item, :q => @query) do - = image_tag item.thumbnail_url, :alt => item.description, :title => item.description - = item.name - = nc_icon_for(item) + = render :partial => 'item_link', :locals => {:item => item} + diff --git a/app/views/items/_item_link.html.haml b/app/views/items/_item_link.html.haml new file mode 100644 index 00000000..11a3a979 --- /dev/null +++ b/app/views/items/_item_link.html.haml @@ -0,0 +1,5 @@ += link_to item_path(item, :q => @query) do + = image_tag item.thumbnail_url, :alt => item.description, :title => item.description + = item.name + = nc_icon_for(item) + diff --git a/config/routes.rb b/config/routes.rb index 74a89a92..cd3e06ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,7 @@ OpenneoImpressItems::Application.routes.draw do |map| resources :user, :only => [] do resources :contributions, :only => [:index] + resources :closet_hangers, :only => [:index], :path => 'closet' end match 'users/top-contributors' => 'users#top_contributors', :as => :top_contributors match 'users/top_contributors' => redirect('/users/top-contributors') diff --git a/public/stylesheets/compiled/closet_hangers/index.css b/public/stylesheets/compiled/closet_hangers/index.css new file mode 100644 index 00000000..f8ef829f --- /dev/null +++ b/public/stylesheets/compiled/closet_hangers/index.css @@ -0,0 +1,4 @@ +/* line 2, ../../../../app/stylesheets/closet_hangers/index.sass */ +body.closet_hangers-index #closet-hangers { + text-align: center; +} diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index c3504025..d7ae053a 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -538,6 +538,11 @@ div.jGrowl div.jGrowl-closer { } } +/* line 2, ../../../app/stylesheets/closet_hangers/index.sass */ +body.closet_hangers-index #closet-hangers { + text-align: center; +} + /* line 1, ../../../app/stylesheets/contributions/_index.sass */ body.contributions-index { text-align: center; diff --git a/spec/controllers/closet_hangers_controller_spec.rb b/spec/controllers/closet_hangers_controller_spec.rb new file mode 100644 index 00000000..6f79ab79 --- /dev/null +++ b/spec/controllers/closet_hangers_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ClosetHangersController do + +end diff --git a/spec/helpers/closet_hangers_helper_spec.rb b/spec/helpers/closet_hangers_helper_spec.rb new file mode 100644 index 00000000..74eee5bb --- /dev/null +++ b/spec/helpers/closet_hangers_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the ClosetHangersHelper. For example: +# +# describe ClosetHangersHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe ClosetHangersHelper do + pending "add some examples to (or delete) #{__FILE__}" +end