diff --git a/server.rb b/server.rb index 3f0746a..b4227ee 100755 --- a/server.rb +++ b/server.rb @@ -11,7 +11,8 @@ DB = Sequel.connect('sqlite://database.db') set :port, 8091 set :nav, [ { title: 'Χρήστες', href: '/users' }, - { title: 'Συνέλευση', href: '/input' } + { title: 'Συνέλευση', href: '/input' }, + { title: 'Ρυθμίσεις', href: '/settings' } ] get '/users' do @@ -72,3 +73,15 @@ post '/save' do ) redirect '/input' 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 diff --git a/views/settings.slim b/views/settings.slim new file mode 100644 index 0000000..c5ea7cb --- /dev/null +++ b/views/settings.slim @@ -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" Αποθήκευση