Skip to content

Commit

Permalink
sprememba in skritje gesla
Browse files Browse the repository at this point in the history
  • Loading branch information
zankastelic committed Sep 15, 2021
1 parent f402468 commit 71a077a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 52 deletions.
Binary file modified Baza/__pycache__/conf_baza.cpython-39.pyc
Binary file not shown.
54 changes: 28 additions & 26 deletions aplikacija.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import psycopg2
import hashlib
import sqlite3
from Baza import conf_baza
#import auth_public as auth

#KONFIGURACIJA
baza_datoteka = 'organizator_nakupov.db'

#Odkomentiraj, če želiš sporočila o napakah
debug(True) # za izpise pri razvoju
#Odkomentiraj, če želiš sporočila o napakah
debug(True) # za izpise pri razvoju

# napakaSporocilo = None

Expand All @@ -20,8 +21,8 @@ def nastaviSporocilo(sporocilo = None):
response.delete_cookie('sporocilo')
else:
response.set_cookie('sporocilo', sporocilo, path="/", secret=skrivnost)
return staro

return staro
# mapa za statične vire (slike,css, ...)
static_dir = "./static"

Expand Down Expand Up @@ -52,7 +53,7 @@ def preveri(uime, geslo):
cur = baza.cursor()
cur.execute("SELECT * FROM osebe WHERE uporanisko_ime=%s AND geslo=%s", (uime, geslo))
result = cur.fetchone()

return result is not None

@get("/static/img/<filepath:re:.*\.(jpg|png|gif|ico|svg)>")
Expand Down Expand Up @@ -99,22 +100,28 @@ def vsi_izdelki_search():
"WHERE ime_izdelka=%s OR firma=%s OR okus=%s", (search, search, search))
return template('vsi_izdelki.html', vsi_izdelki = cur.fetchall())

@post('vsi_izdelki/dodaj')
def dodaj_izdelke():
# @post('vsi_izdelki/dodaj')
# def dodaj_izdelke():
# id_izdelka = request.forms.get('id_izdelka')
# ime_trgovine = request.forms.get('ime_trgovine')
# ime_izdelka = request.forms.get('ime_izdelka')
# firma = request.forms.get('firma')
# okus = request.forms.get('okus')
# redna_cena = request.forms.get('redna_cena')
# teza = request.forms.get('teza')
# cur = baza.cursor()
# cur.execute("INSERT INTO vsi_izdelki (id_izdelka, ime_trgovine, ime_izdelka, firma, okus, redna_cena, teza) VALUES (%s, %s, %s, %s, %s, %s, %s)", (id_izdelka, ime_trgovine, ime_izdelka, firma, okus, redna_cena, teza))
# redirect('/vsi_izdelki')

@post('/dodaj_kosarica')
def kosarica():
kolicina = request.forms.get('kolicina')
id_izdelka = request.forms.get('id_izdelka')
ime_trgovine = request.forms.get('ime_trgovine')
ime_izdelka = request.forms.get('ime_izdelka')
firma = request.forms.get('firma')
okus = request.forms.get('okus')
redna_cena = request.forms.get('redna_cena')
teza = request.forms.get('teza')
#kako dobiš uporabnika vn
cur = baza.cursor()
cur.execute("INSERT INTO vsi_izdelki (id_izdelka, ime_trgovine, ime_izdelka, firma, okus, redna_cena, teza) VALUES (?, ?, ?, ?, ?, ?, ?)", (id_izdelka, ime_trgovine, ime_izdelka, firma, okus, redna_cena, teza))
cur.execute("INSERT INTO kosarica (id,kolicina,id_izdelka,uporabnik) VALUES (%s,%s,%s,%s)", (neki, kolicina, id_izdelka, neki_neki))
redirect('/vsi_izdelki')

#@get('/kosarica')
#def kosarica():



@get('/osebe')
Expand All @@ -124,21 +131,16 @@ def osebe():
osebe = cur.execute("SELECT uporabnisko_ime, geslo, ime, priimek FROM osebe")
return template('osebe.html', osebe = cur)

@get('/trgovine')
def trgovine():
con = sqlite3.connect(baza_datoteka)
cur = con.cursor()
trgovine = cur.execute("SELECT id, ime, kraj FROM trgovine")
return template('trgovine.html', osebe = cur)


# straženje statičnih datotek
# straženje statičnih datotek
@route("/static/<filename:path>")
def static(filename):
return static_file(filename, root=static_dir)


#baza = psycopg2.connect(database=auth.dbname, host=auth.host, user=auth.user, password=auth.password)
# with psycopg2.connect(host="baza.fmf.uni-lj.si", database="sem2021_zanka", user="zanka", password="Slucajne1996") as baza:
baza = psycopg2.connect(host=conf_baza.host, database=conf_baza.dbname, user=conf_baza.user, password=conf_baza.password)
#baza.set_trace_cal back(print) #kakšne SQL stavke pošilja nazaj - izpis SQL stavkov (za debugiranje pri razvoju)
# zapoved upoštevanja omejitev FOREIGN KEY
cur = baza.cursor()
Expand All @@ -150,5 +152,5 @@ def static(filename):
print('tp')
baza.commit()

# reloader=True nam olajša razvoj (osveževanje sproti - razvoj)
# reloader=True nam olajša razvoj (osveževanje sproti - razvoj)
run(host='localhost', port=8080, debug=True)
1 change: 1 addition & 0 deletions static/stili.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ body {
.vodoravno{
display: flex;
flex-direction: row;
align-items: center;
}

.gumb{
Expand Down
22 changes: 0 additions & 22 deletions views/trgovine.html

This file was deleted.

6 changes: 2 additions & 4 deletions views/vsi_izdelki.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
border-spacing: 1;
width: 100%;
border: 1px solid powderblue;
background-color: powderblue;
}

th, td {
text-align: center;
padding: 16px;
border: 1px solid black;
}

tr:nth-child(even) {
background-color: powderblue;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -73,6 +70,7 @@ <h2>Začnite nakupovati</h2>
<option value="9">9</option>
<option value="10">10</option>
</select>
<input name="id_izdelka" value="{{id_izdelka}}" type="hidden">
<input value="Dodaj v košarico" class="gumb" type="submit">
</form>
</td>
Expand Down

0 comments on commit 71a077a

Please sign in to comment.