newest items
This commit is contained in:
parent
b939c7fce6
commit
d99a1ad792
7 changed files with 53 additions and 27 deletions
|
@ -32,7 +32,10 @@ class ItemsController < ApplicationController
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render }
|
format.html {
|
||||||
|
@newest_items = Item.newest.limit(9)
|
||||||
|
render
|
||||||
|
}
|
||||||
format.js { render :json => {:error => '$q required'}}
|
format.js { render :json => {:error => '$q required'}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,8 @@ class Item < ActiveRecord::Base
|
||||||
"LEFT JOIN #{SwfAsset.table_name} sa ON sa.type = 'object' AND sa.id = psa.swf_asset_id"
|
"LEFT JOIN #{SwfAsset.table_name} sa ON sa.type = 'object' AND sa.id = psa.swf_asset_id"
|
||||||
).where('sa.id IS NULL')
|
).where('sa.id IS NULL')
|
||||||
|
|
||||||
|
scope :newest, order(arel_table[:created_at].desc)
|
||||||
|
|
||||||
scope :spidered_longest_ago, order(["(#{Item.arel_table[:last_spidered].eq(nil).to_sql}) DESC", arel_table[:last_spidered].desc])
|
scope :spidered_longest_ago, order(["(#{Item.arel_table[:last_spidered].eq(nil).to_sql}) DESC", arel_table[:last_spidered].desc])
|
||||||
|
|
||||||
scope :sold_in_mall, where(:sold_in_mall => true)
|
scope :sold_in_mall, where(:sold_in_mall => true)
|
||||||
|
|
|
@ -8,7 +8,7 @@ body.items-index
|
||||||
form
|
form
|
||||||
margin-bottom: 2em
|
margin-bottom: 2em
|
||||||
|
|
||||||
#search-help
|
#search-info
|
||||||
+main_unit
|
+main_unit
|
||||||
padding-right: 1%
|
padding-right: 1%
|
||||||
dl
|
dl
|
||||||
|
@ -22,3 +22,4 @@ body.items-index
|
||||||
img
|
img
|
||||||
height: 80px
|
height: 80px
|
||||||
width: 80px
|
width: 80px
|
||||||
|
|
||||||
|
|
|
@ -13,26 +13,31 @@
|
||||||
= render @items
|
= render @items
|
||||||
= will_paginate @items
|
= will_paginate @items
|
||||||
- else
|
- else
|
||||||
#search-help
|
#search-info
|
||||||
%h2 Find what you're looking for
|
#search-help
|
||||||
%dl
|
%h2 Find what you're looking for
|
||||||
%dt kreludor "altador cup" -background
|
%dl
|
||||||
%dd
|
%dt kreludor "altador cup" -background
|
||||||
returns any item with the word "kreludor" and the phrase "altador cup"
|
%dd
|
||||||
in it, but not the word "background"
|
returns any item with the word "kreludor" and the phrase "altador cup"
|
||||||
%dt hat user:owns
|
in it, but not the word "background"
|
||||||
%dd
|
%dt hat user:owns
|
||||||
returns
|
%dd
|
||||||
= link_to 'items that you own', your_items_path
|
returns
|
||||||
with the word "hat"
|
= link_to 'items that you own', your_items_path
|
||||||
%dt blue is:nc
|
with the word "hat"
|
||||||
%dd returns any NC Mall item with the word "blue" in it
|
%dt blue is:nc
|
||||||
%dt collar -is:pb
|
%dd returns any NC Mall item with the word "blue" in it
|
||||||
%dd returns any item with the word "collar" in it that isn't from a paint brush
|
%dt collar -is:pb
|
||||||
%dt species:shoyru
|
%dd returns any item with the word "collar" in it that isn't from a paint brush
|
||||||
%dd returns any item a Shoyru can wear
|
%dt species:shoyru
|
||||||
%dt type:hat
|
%dd returns any item a Shoyru can wear
|
||||||
%dd returns any item that fills a "hat" zone
|
%dt type:hat
|
||||||
|
%dd returns any item that fills a "hat" zone
|
||||||
|
|
||||||
|
#search-new-items
|
||||||
|
%h2 Newest items
|
||||||
|
= render @newest_items
|
||||||
|
|
||||||
#species-search-links
|
#species-search-links
|
||||||
%h2 Can't decide? Search by species
|
%h2 Can't decide? Search by species
|
||||||
|
|
13
db/migrate/20110804134432_add_timestamps_to_items.rb
Normal file
13
db/migrate/20110804134432_add_timestamps_to_items.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class AddTimestampsToItems < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_timestamps :objects
|
||||||
|
|
||||||
|
timestamp_query = "(SELECT created_at FROM contributions WHERE contributed_id = objects.id AND contributed_type = 'Item')"
|
||||||
|
update "UPDATE objects SET created_at = #{timestamp_query}, updated_at = #{timestamp_query}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_timestamps :objects
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20110731021808) do
|
ActiveRecord::Schema.define(:version => 20110804134432) do
|
||||||
|
|
||||||
create_table "auth_servers", :force => true do |t|
|
create_table "auth_servers", :force => true do |t|
|
||||||
t.string "short_name", :limit => 10, :null => false
|
t.string "short_name", :limit => 10, :null => false
|
||||||
|
@ -86,6 +86,8 @@ ActiveRecord::Schema.define(:version => 20110731021808) do
|
||||||
t.text "species_support_ids", :limit => 16777215
|
t.text "species_support_ids", :limit => 16777215
|
||||||
t.boolean "sold_in_mall", :null => false
|
t.boolean "sold_in_mall", :null => false
|
||||||
t.datetime "last_spidered"
|
t.datetime "last_spidered"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "objects", ["last_spidered"], :name => "objects_last_spidered"
|
add_index "objects", ["last_spidered"], :name => "objects_last_spidered"
|
||||||
|
|
|
@ -1638,21 +1638,21 @@ body.items-index form {
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
/* line 11, ../../../app/stylesheets/items/_index.sass */
|
/* line 11, ../../../app/stylesheets/items/_index.sass */
|
||||||
body.items-index #search-help {
|
body.items-index #search-info {
|
||||||
float: left;
|
float: left;
|
||||||
width: 49%;
|
width: 49%;
|
||||||
padding-right: 1%;
|
padding-right: 1%;
|
||||||
}
|
}
|
||||||
/* line 4, ../../../app/stylesheets/items/_index.sass */
|
/* line 4, ../../../app/stylesheets/items/_index.sass */
|
||||||
body.items-index #search-help h2 {
|
body.items-index #search-info h2 {
|
||||||
font-size: 125%;
|
font-size: 125%;
|
||||||
}
|
}
|
||||||
/* line 14, ../../../app/stylesheets/items/_index.sass */
|
/* line 14, ../../../app/stylesheets/items/_index.sass */
|
||||||
body.items-index #search-help dl {
|
body.items-index #search-info dl {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
/* line 16, ../../../app/stylesheets/items/_index.sass */
|
/* line 16, ../../../app/stylesheets/items/_index.sass */
|
||||||
body.items-index #search-help dd {
|
body.items-index #search-info dd {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
/* line 19, ../../../app/stylesheets/items/_index.sass */
|
/* line 19, ../../../app/stylesheets/items/_index.sass */
|
||||||
|
|
Loading…
Reference in a new issue