Example #1
0
def apply_loan(worker_id):
    """
    Display workers apply-loan html fill out form
    """
    if request.method == "POST":
        info = request.form
        workers = storage.all(Worker)
        number = None
        for wor in workers.values():
            if wor.worker == worker_id:
                number = wor
        if number is None:
            number = Worker()
        number.worker = worker_id
        number.request_date = info['date']
        number.type_loan = info['type-loan']
        number.amount_request = info['amount']

        mka = storage
        mka.new(number)
        mka.save()
        mka.close()

        return redirect('/loan-details/{}'.format(number.id), code=302)
    return render_template('apply_loan.html',
                           id=str(uuid.uuid4()),
                           person_id=worker_id)
Example #2
0
def id_worker():
    """ Worker subscription form """
    if request.method == "POST":
        info = request.form
        obj = User()
        obj.username = info['username']
        obj.email = info['email']
        obj.psswd = info['password']
        obj.status = "active"
        data = Person()
        data.user = obj.id
        data.first_name = info['fname']
        data.last_name = info['lname']
        data.type_id = info['tipo-identificacion']
        data.number_identification = info['numberID']
        data.born_date = info['date']
        wor = Worker()
        wor.worker = data.id
        mka = storage
        mka.reload()
        mka.new(obj)
        mka.save()
        mka.new(data)
        mka.save()
        mka.new(wor)
        mka.save()
        mka.close()
        return redirect('/profile-worker/{}'.format(data.id), code=302)
    return render_template('sign_up_worker.html', id=str(uuid.uuid4()))