diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index f41d3445..6f47ee54 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -114,14 +114,15 @@ class ItemsController < ApplicationController def sources item_ids = params[:ids].split(",") - @items = Item.where(id: item_ids).order(:name) + @items = Item.where(id: item_ids).includes(:nc_mall_record).order(:name) if @items.empty? render file: "public/404.html", status: :not_found, layout: nil return end - @nc_items = @items.select(&:nc?) + @nc_mall_items = @items.select(&:currently_in_mall?) + @other_nc_items = @items.select(&:nc?).reject(&:currently_in_mall?) @np_items = @items.select(&:np?) @pb_items = @items.select(&:pb?) diff --git a/app/models/item.rb b/app/models/item.rb index 6db92d53..49b9c3c9 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -8,6 +8,7 @@ class Item < ApplicationRecord has_many :closet_hangers has_one :contribution, :as => :contributed, :inverse_of => :contributed + has_one :nc_mall_record has_many :parent_swf_asset_relationships, :as => :parent has_many :swf_assets, :through => :parent_swf_asset_relationships @@ -162,6 +163,10 @@ class Item < ApplicationRecord !nc? && !pb? end + def currently_in_mall? + nc_mall_record.present? + end + def owned? @owned || false end diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index 0fe98f94..296c28d0 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -1,9 +1,9 @@ - title "Item Getting Guide" %h1#title Item Getting Guide -- if @nc_items.present? - %h2 Neocash items - = render @nc_items +- if @nc_mall_items.present? + %h2 NC Mall items + = render @nc_mall_items - if @np_items.present? %h2 Neopoint items @@ -12,3 +12,7 @@ - if @pb_items.present? %h2 Paintbrush items = render @pb_items + +- if @other_nc_items.present? + %h2 Other NC items + = render @other_nc_items