2022-12-07 17:52:27 -05:00
|
|
|
get '/' do
|
2022-12-08 17:26:44 -05:00
|
|
|
items = Item.reverse(:updated_at).limit(10).all()
|
2022-12-07 17:52:27 -05:00
|
|
|
erb :index, :locals => {
|
|
|
|
:title => 'Dashboard',
|
|
|
|
:items => items
|
|
|
|
}
|
|
|
|
end
|
2022-12-07 20:12:23 -05:00
|
|
|
|
|
|
|
get '/item' do
|
|
|
|
redirect '/item/list'
|
|
|
|
end
|
|
|
|
get '/item/list' do
|
2022-12-08 17:26:44 -05:00
|
|
|
items = Item.reverse(:updated_at).all()
|
2022-12-07 20:12:23 -05:00
|
|
|
erb :'item/list', :locals => {
|
|
|
|
:title => 'List of Items',
|
|
|
|
:items => items
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/item/create' do
|
|
|
|
erb :'item/create', :locals => {
|
|
|
|
:title => 'Create New Item'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
post '/item/create' do
|
|
|
|
item = Item.create(
|
|
|
|
name: params[:item_name],
|
|
|
|
serial_number: params[:item_serial],
|
|
|
|
sku_number: params[:item_sku],
|
|
|
|
purchased_from: params[:item_purchase_from],
|
|
|
|
purchased_at: params[:item_purchase_date],
|
|
|
|
manufacturer: params[:item_manufacturer],
|
|
|
|
type: params[:item_type]
|
|
|
|
)
|
|
|
|
|
|
|
|
redirect "/item/#{item.id}"
|
|
|
|
end
|
2022-12-08 01:12:31 -05:00
|
|
|
|
|
|
|
get '/item/:item_id' do
|
|
|
|
item = Item.where(id: params[:item_id]).first
|
|
|
|
puts "#{item.name}"
|
|
|
|
erb :'item/view', :locals => {
|
|
|
|
:title => item.name,
|
|
|
|
:item => item
|
|
|
|
}
|
|
|
|
end
|
2022-12-08 01:32:41 -05:00
|
|
|
|
|
|
|
post '/item/:item_id/comment' do
|
|
|
|
item = Item.first(id: params[:item_id])
|
|
|
|
|
|
|
|
comment = ItemComment.create(body: params[:comment_body])
|
|
|
|
item.add_item_comment(comment)
|
|
|
|
|
|
|
|
redirect "/item/#{item.id}"
|
|
|
|
end
|
2022-12-08 17:26:44 -05:00
|
|
|
|
|
|
|
get '/license' do
|
|
|
|
redirect '/license/list'
|
|
|
|
end
|
|
|
|
get '/license/list' do
|
|
|
|
licenses = License.reverse(:updated_at).all()
|
|
|
|
erb :'license/list', :locals => {
|
|
|
|
:title => 'List of Licenses',
|
|
|
|
:licenses => licenses
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/license/create' do
|
|
|
|
erb :'license/create', :locals => {
|
|
|
|
:title => 'Create New License'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
post '/license/create' do
|
|
|
|
license = License.create(
|
|
|
|
name: params[:license_name],
|
|
|
|
key: params[:license_key],
|
|
|
|
manufacturer: params[:license_manufacturer],
|
|
|
|
seats_used: params[:license_seats_used],
|
|
|
|
seats_total: params[:license_seats_total],
|
|
|
|
purchased_from: params[:license_purchase_from],
|
|
|
|
purchased_at: params[:license_purchase_date]
|
|
|
|
)
|
|
|
|
|
|
|
|
redirect "/license/#{license.id}"
|
|
|
|
end
|
|
|
|
|
|
|
|
get '/license/:license_id' do
|
|
|
|
license = License.where(id: params[:license_id]).first()
|
|
|
|
puts "#{license.name}"
|
|
|
|
erb :'license/view', :locals => {
|
|
|
|
:title => license.name,
|
|
|
|
:license => license
|
|
|
|
}
|
|
|
|
end
|