Class: Dscf::Marketplace::ListingsController
- Inherits:
-
ApplicationController
- Object
- Core::ApplicationController
- ApplicationController
- Dscf::Marketplace::ListingsController
- Includes:
- Core::Common
- Defined in:
- app/controllers/dscf/marketplace/listings_controller.rb
Instance Method Summary collapse
- #activate ⇒ Object
- #listings_by_supplier ⇒ Object
- #my_listings ⇒ Object
- #pause ⇒ Object
- #sold_out ⇒ Object
Instance Method Details
#activate ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 6 def activate @obj = find_record @obj, :activate? if @obj.update(status: :active) render_success("listings.success.activated", data: @obj) else render_error("listings.errors.activate_failed") end end |
#listings_by_supplier ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 49 def listings_by_supplier @clazz.new, :listings_by_supplier? supplier_id = params[:supplier_id] # Validate supplier exists supplier = Dscf::Core::Business.find_by(id: supplier_id) return render_error("listings.errors.supplier_not_found") unless supplier service = MyResourceService.new(current_user) listings = service.listings_by_supplier(supplier_id, params) = { include: default_serializer_includes[:index] || [], meta: { resource_type: "listings_by_supplier", supplier_id: supplier_id, supplier_name: supplier.name } } render_success("listings.success.index", data: listings, serializer_options: ) end |
#my_listings ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 36 def my_listings @clazz.new, :my_listings? service = MyResourceService.new(current_user) listings = service.my_listings(params) = { include: default_serializer_includes[:index] || [], meta: {resource_type: "my_listings"} } render_success("listings.success.index", data: listings, serializer_options: ) end |
#pause ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 16 def pause @obj = find_record @obj, :pause? if @obj.update(status: :paused) render_success("listings.success.paused", data: @obj) else render_error("listings.errors.pause_failed") end end |
#sold_out ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/dscf/marketplace/listings_controller.rb', line 26 def sold_out @obj = find_record @obj, :sold_out? if @obj.update(status: :sold_out) render_success("listings.success.sold_out", data: @obj) else render_error("listings.errors.sold_out_failed") end end |