Add settings page

This commit is contained in:
George Kaklamanos 2019-11-10 23:04:38 +02:00
parent 2178a07ced
commit 169082c07a
2 changed files with 29 additions and 1 deletions

View file

@ -11,7 +11,8 @@ DB = Sequel.connect('sqlite://database.db')
set :port, 8091 set :port, 8091
set :nav, [ set :nav, [
{ title: 'Χρήστες', href: '/users' }, { title: 'Χρήστες', href: '/users' },
{ title: 'Συνέλευση', href: '/input' } { title: 'Συνέλευση', href: '/input' },
{ title: 'Ρυθμίσεις', href: '/settings' }
] ]
get '/users' do get '/users' do
@ -72,3 +73,15 @@ post '/save' do
) )
redirect '/input' redirect '/input'
end end
get '/settings' do
l = {}
l[:user_settings] = DB[:settings].first
slim :settings, locals: l
end
post '/settings' do
DB[:settings].update(max_apousies: params['max_apousies'],
prova_cost: params['prova_cost'])
redirect '/settings'
end

15
views/settings.slim Normal file
View file

@ -0,0 +1,15 @@
doctype html
html
head
include head
body
include nav
.container role="main"
form method="post" action="/settings"
div.form-group.row
label.col-form-label.col-sm-2 for="max_apousies" Max. # Απουσιών
input#max_apousies.form-control.col-sm-1 type="number" name="max_apousies" value="#{user_settings[:max_apousies]}"
div.form-group.row
label.col-form-label.col-sm-2 for="prova_cost" Κόστος πρόβας
input#prova_cost.form-control.col-sm-1 type="number" name="prova_cost" value="#{user_settings[:prova_cost]}"
button.btn.btn-primary name="submit" type="submit" Αποθήκευση