Add user info page

This commit is contained in:
George Kaklamanos 2019-11-10 22:27:32 +02:00
parent cf7c86490e
commit 46bc6dcbf3
2 changed files with 72 additions and 0 deletions

View file

@ -19,3 +19,22 @@ get '/users' do
slim :users, locals: l
end
get '/user' do
l = {}
l[:user] = DB[:user].where(id: params['uid']).first
l[:logs] = DB[:log_entry].where(id: params['uid']).reverse(:timestamp).all
slim :user, locals: l
end
post '/user' do
DB[:user].where(id: params['uid']).update(
name: params['name'],
email: params['email'],
phone: params['phone'],
card_number: params['card-number'],
apousies: params['apousies'],
balance: params['balance'],
telegram_id: params['telegram-id']
)
redirect '/user?uid=' + params['uid']
end

53
views/user.slim Normal file
View file

@ -0,0 +1,53 @@
doctype html
html
head
include head
body
include nav
#main.mx-auto
h1=user[:name]
h2 Επεξεργασία στοιχείων
form method="post" action="/user"
div.input-group
input type="hidden" name="uid" value="#{user[:id]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="name" Όνομα
input#name.form-control.col-sm-3 type="text" name="name" value="#{user[:name]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="email" E-mail
input#email.form-control.col-sm-3 type="text" name="email" value="#{user[:email]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="phone" Τηλέφωνο
input#phone.form-control.col-sm-2 type="text" name="phone" value="#{user[:phone]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="card-number" Αρ. Κάρτας
input#card.form-control.col-sm-1 type="text" name="card-number" value="#{user[:card_number]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="apousies" Απουσίες
input#apousies.form-control.col-sm-1 type="text" name="apousies" value="#{user[:apousies]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="balance" Balance
input#balance.form-control.col-sm-1 type="text" name="balance" value="#{user[:balance]}"
div.input-group.form-group.row
label.col-form-label.col-sm-2 for="telegram-id" Telegram ID
input#telegram-id.form-control.col-sm-1 type="text" name="telegram-id" value="#{user[:telegram_id]}"
button.btn.btn-primary type="submit" Αποθήκευση στοιχείων
h1 Ιστορικό
table.table.table-hover.table-inverse
tr
th Ποσό πληρωμής
th Ποσό δωρεάς
th Σχόλια
th Banned
th Έκανε απουσία
th Είναι στο προεδρείο
th Έχει ασυλία
- logs.each do |l|
tr
td=l[:amount_paid]
td=l[:amount_donated]
td=l[:comments]
td=get_boolean(l[:ban])
td=get_boolean(l[:apousia])
td=get_boolean(l[:proedreio])
td=get_boolean(l[:asylia])