Beispiel #1
0
def off_work(request: Request,  ssn: str = Form(...)):
    et = time.strftime('%Y-%m-%d %H:%M:%S')
    cid = et[:4] + et[5:7] + et[8:10] + ssn
    conn.execute(commutes.update().values(et=et).where(commutes.c.id == cid))
    return templates.TemplateResponse('commute/out.html', {"request": request})
Beispiel #2
0
def show_commute(request: Request):
    result = conn.execute(select([persons.c.ssn, persons.c.name, commutes.c.st, commutes.c.et]).
                          select_from(persons.join(commutes))).fetchall()
    return templates.TemplateResponse('commute/show.html', {'request': request, 'result': result})
Beispiel #3
0
def truncate_person():
    return conn.execute(persons.delete())
Beispiel #4
0
def go_to_work(request: Request,  ssn: str = Form(...)):
    st = time.strftime('%Y-%m-%d %H:%M:%S')
    cid = st[:4] + st[5:7] + st[8:10] + ssn
    conn.execute(commutes.insert().values(id=cid, ssn=ssn, st=st, et=None))
    return templates.TemplateResponse('commute/in.html', {"request": request})
Beispiel #5
0
def update_person(request: Request,  ssn: str = Form(...), name: str = Form(...), age: int = Form(...),
                  tel: str = Form(...)):
    conn.execute(persons.update().values(name=name, age=age,
                                         tel=tel).where(persons.c.ssn == ssn))
    return templates.TemplateResponse('person/update.html', {"request": request})
Beispiel #6
0
def delete_person(request: Request, ssn: str = Form(...)):
    conn.execute(persons.delete().where(persons.c.ssn == ssn))
    return templates.TemplateResponse('person/delete.html', {"request": request})
Beispiel #7
0
def show_person(request: Request):
    result = conn.execute(persons.select()).fetchall()
    return templates.TemplateResponse('person/show.html', {'request': request, 'result': result})
Beispiel #8
0
def create_person(request: Request,  ssn: str = Form(...), name: str = Form(...), age: int = Form(...),
                  tel: str = Form(...)):
    conn.execute(persons.insert().values(ssn=ssn, name=name, age=age, tel=tel))
    return templates.TemplateResponse('person/create.html', {"request": request})
Beispiel #9
0
def fetch_all():
    return conn.execute(persons.select()).fetchall()
Beispiel #10
0
def show_one_pay(request: Request, ssn: str = Form(...)):
    result = conn.execute(select([persons.c.ssn, persons.c.name, payments.c.money, payments.c.date]).
                          select_from(persons.join(payments)).where(payments.c.ssn == ssn)).fetchall()
    return templates.TemplateResponse('payment/show.html', {'request': request, 'result': result})
Beispiel #11
0
def pay_salary(request: Request,  ssn: str = Form(...), money: int = Form(...)):
    pay_date = time.strftime('%Y-%m-%d %H:%M:%S')
    conn.execute(payments.insert().values(ssn=ssn, money=money, date=pay_date))
    return templates.TemplateResponse('payment/pay.html', {"request": request})