groups of articles now shown on ribica.ba/group/1/, background is in cloudinary
This commit is contained in:
@@ -73,6 +73,7 @@ get '/item/sub_category/:sub_category_id/offset/:offset/limit/:limit' do |sub_ca
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
|
||||
|
||||
# gets list of items in cart without count
|
||||
get '/cart/item_details' do
|
||||
cart = Cart.find_or_create(anonymous_id, -1)
|
||||
@@ -83,3 +84,14 @@ get '/cart/item_details' do
|
||||
items = Item.find(item_ids) if cart.item_in_carts.length > 0
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
|
||||
|
||||
# gets items in sub category ( useful for page showing single sub_category )
|
||||
get '/item/item_group/:item_group_id/offset/:offset/limit/:limit' do |item_group_id_s, offset_s, limit_s|
|
||||
item_group_id, offset, limit = mass_to_i(item_group_id_s, offset_s, limit_s)
|
||||
input_invalid = offset_and_limit_invalid?(offset,limit) or item_group_id <= 0
|
||||
return [].to_json if input_invalid
|
||||
|
||||
items = ItemGroup.find(item_group_id).all_items(offset, limit)
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
8
front-api/models/item_group.rb
Normal file
8
front-api/models/item_group.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class ItemGroup < ActiveRecord::Base
|
||||
has_and_belongs_to_many :items, :join_table => 'item_item_groups'
|
||||
|
||||
def all_items(offset, limit)
|
||||
self.items.where(on_display: true).order(:created_at).limit(limit).offset(offset).all
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user