mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 19:48:28 +02:00
Added pricelist to admin #2380
This commit is contained in:
parent
a262e1e708
commit
4b5243585d
101 changed files with 3155 additions and 76 deletions
44
app/controllers/admin/pricelists_controller.rb
Normal file
44
app/controllers/admin/pricelists_controller.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
class Admin::PricelistsController < AdminController
|
||||
load_and_authorize_resource
|
||||
before_action :set_pricelist, only: [:show, :edit, :update]
|
||||
|
||||
def index
|
||||
@q = Pricelist.search(params[:q])
|
||||
@pricelists = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def new
|
||||
@pricelist = Pricelist.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@pricelist = Pricelist.new(pricelist_params)
|
||||
|
||||
if @pricelist.save
|
||||
redirect_to admin_pricelists_url
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @pricelist.update_attributes(pricelist_params)
|
||||
redirect_to admin_pricelists_url
|
||||
else
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_pricelist
|
||||
@pricelist = Pricelist.find(params[:id])
|
||||
end
|
||||
|
||||
def pricelist_params
|
||||
params.require(:pricelist).permit(:category, :name, :duration, :price, :valid_from, :valid_to)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue