Beispiel #1
0
def main_korisnici():
    if request.method == 'GET':
        korisnici = Korisnici.listaj()
        return jsonify({"korisnici": korisnici})
    elif request.method == 'POST':
        status, greske = Korisnici.dodaj(request.get_json())
        if status:
            return Response(status=201)
        else:
            r = Response(status=500)
            r.set_data(greske)
            return r
Beispiel #2
0
def handleSignUp():
    status, errors = Korisnici.dodaj(request.get_json())
    if status:
        return Response(status=201)
    else:
        r = Response(status=500)
        r.set_data(errors)
        return r
Beispiel #3
0
def korisnici():
    if request.method == 'GET':
        return render_template('registracija.html')
    elif request.method == 'POST':
        novi_korisnik = {
            "Ime": request.form["Ime"],
            "Prezime": request.form["Prezime"],
            "Adresa": request.form["Adresa"],
            "Username": request.form["Username"],
            "Password": request.form["Password"]
        }
        status, greske = Korisnici.dodavanje(novi_korisnik)
        if status:
            return render_template('index.html')
        else:
            r = Response(status=500)
            r.set_data(greske)
            return r
Beispiel #4
0
def prijava():
    global trenutni_korisnik_g
    if request.method == 'GET':
        return render_template('prijava.html')
    elif request.method == 'POST':
        trenutni_korisnik = {
            "Username": request.form["Username"],
            "Password": request.form["Password"]
        }
        status = Korisnici.prijava(trenutni_korisnik)
        if status == False:
            r = Response(status=500)
            return r
        else:

            trenutni_korisnik_g = status
            troskovi = Troskovi.izlistavanje(trenutni_korisnik_g[0]["id"])
            prihodi = Prihodi.izlistavanje(trenutni_korisnik_g[0]["id"])
            izvjesce = Izvjesca.izlistavanje(trenutni_korisnik_g[0]["id"])

            if prihodi == [] and troskovi[0] == []:
                return render_template('profil.html', korisnik=status)
            elif prihodi == []:
                return render_template('profil.html',
                                       korisnik=status,
                                       troskovi=troskovi[0])
            elif troskovi[0] == []:
                return render_template('profil.html',
                                       korisnik=status,
                                       prihodi=prihodi)

            else:
                return render_template('profil.html',
                                       troskovi=troskovi[0],
                                       prihodi=prihodi,
                                       izvjesce=izvjesce[0],
                                       korisnik=status)
Beispiel #5
0
def handleLogin(email, lozinka):
    email = str(email)
    lozinka = str(lozinka)
    login = Korisnici.prijava(email, lozinka)
    return jsonify(login)
Beispiel #6
0
def handleUsers():
    users = Korisnici.listaj()
    return jsonify({"data": users})