Class: Caboose::VendorsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Caboose::VendorsController
- Defined in:
- app/controllers/caboose/vendors_controller.rb
Instance Method Summary collapse
-
#admin_add ⇒ Object
POST /admin/vendors.
-
#admin_delete ⇒ Object
DELETE /admin/vendors/:id.
-
#admin_edit ⇒ Object
GET /admin/vendors/:id.
-
#admin_index ⇒ Object
GET /admin/vendors.
-
#admin_new ⇒ Object
GET /admin/vendors/new.
-
#admin_update ⇒ Object
PUT /admin/vendors/:id/update.
-
#admin_update_image ⇒ Object
POST /admin/vendors/:id/update/image.
-
#status_options ⇒ Object
GET /admin/vendors/status-options.
Methods inherited from ApplicationController
#admin_bulk_add, #admin_bulk_delete, #admin_bulk_update, #admin_json, #admin_json_single, #before_action, #before_before_action, #hashify_query_string, #init_cart, #logged_in?, #logged_in_user, #login_user, #logout_user, #parse_url_params, #reject_param, #user_is_allowed, #user_is_allowed_to, #validate_cookie, #validate_token, #var, #verify_logged_in
Instance Method Details
#admin_add ⇒ Object
POST /admin/vendors
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/caboose/vendors_controller.rb', line 69 def admin_add return if !user_is_allowed('vendors', 'add') render :json => { :success => false, :message => 'Must define a name' } and return if params[:name].nil? || params[:name].empty? vendor = Vendor.new( :site_id => @site.id, :name => params[:name], :status => 'Active' ) render :json => { :success => vendor.save, :redirect => "/admin/vendors/#{vendor.id}" } end |
#admin_delete ⇒ Object
DELETE /admin/vendors/:id
83 84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/caboose/vendors_controller.rb', line 83 def admin_delete return if !user_is_allowed('vendors', 'delete') v = Vendor.find(params[:id]) v.destroy resp = StdClass.new({ 'redirect' => '/admin/vendors' }) render :json => resp end |
#admin_edit ⇒ Object
GET /admin/vendors/:id
26 27 28 29 30 |
# File 'app/controllers/caboose/vendors_controller.rb', line 26 def admin_edit return if !user_is_allowed('vendors', 'edit') @vendor = Vendor.find(params[:id]) render :layout => 'caboose/admin' end |
#admin_index ⇒ Object
GET /admin/vendors
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/caboose/vendors_controller.rb', line 5 def admin_index return if !user_is_allowed('vendors', 'view') @pager = Caboose::Pager.new(params, { 'site_id' => @site.id, 'name_like' => '' }, { 'model' => 'Caboose::Vendor', 'sort' => 'name', 'desc' => false, 'base_url' => '/admin/vendors', 'items_per_page' => 25, 'use_url_params' => false }); @vendors = @pager.items render :layout => 'caboose/admin' end |
#admin_new ⇒ Object
GET /admin/vendors/new
63 64 65 66 |
# File 'app/controllers/caboose/vendors_controller.rb', line 63 def admin_new return if !user_is_allowed('vendors', 'add') render :layout => 'caboose/admin' end |
#admin_update ⇒ Object
PUT /admin/vendors/:id/update
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/caboose/vendors_controller.rb', line 33 def admin_update return if !user_is_allowed('vendors', 'edit') vendor = Vendor.find(params[:id]) params.each do |name, value| case name when 'site_id' then vendor.site_id = value when 'name' then vendor.name = value when 'status' then vendor.status = value when 'featured' then vendor.featured = value end end render :json => { :success => vendor.save } end |
#admin_update_image ⇒ Object
POST /admin/vendors/:id/update/image
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/caboose/vendors_controller.rb', line 50 def admin_update_image return if !user_is_allowed('vendors', 'edit') vendor = Vendor.find(params[:id]) vendor.image = params[:image] vendor.save resp = StdClass.new resp.attributes = { :image => { :value => vendor.image.url(:thumb) }} resp.success = vendor.save end |
#status_options ⇒ Object
GET /admin/vendors/status-options
95 96 97 98 99 100 101 |
# File 'app/controllers/caboose/vendors_controller.rb', line 95 def render :json => [ { :text => 'Active' , :value => 'Active' }, { :text => 'Inactive' , :value => 'Inactive' }, { :text => 'Deleted' , :value => 'Deleted' } ] end |