Added License model and views
This commit is contained in:
5
lib/models/license.rb
Normal file
5
lib/models/license.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class License < Sequel::Model
|
||||
|
||||
|
||||
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
get '/' do
|
||||
items = Item.all
|
||||
items = Item.reverse(:updated_at).limit(10).all()
|
||||
erb :index, :locals => {
|
||||
:title => 'Dashboard',
|
||||
:items => items
|
||||
@ -10,7 +10,7 @@ get '/item' do
|
||||
redirect '/item/list'
|
||||
end
|
||||
get '/item/list' do
|
||||
items = Item.all
|
||||
items = Item.reverse(:updated_at).all()
|
||||
erb :'item/list', :locals => {
|
||||
:title => 'List of Items',
|
||||
:items => items
|
||||
@ -53,3 +53,42 @@ post '/item/:item_id/comment' do
|
||||
|
||||
redirect "/item/#{item.id}"
|
||||
end
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user