From 63dc8120962f2099f741bb0f336058795ef5d203 Mon Sep 17 00:00:00 2001 From: Bernhard Stampfer Date: Sat, 20 Feb 2016 19:03:31 +0100 Subject: [PATCH] - web-if and gui now respect isshown and isblack flags --- app/database.py | 2 +- app/gui.py | 33 ++++++++++++++++++--------------- app/templates/consume.html | 14 ++++++++++---- test/database.db | Bin 57344 -> 57344 bytes 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/database.py b/app/database.py index 50c5ec1..32c6155 100644 --- a/app/database.py +++ b/app/database.py @@ -100,7 +100,7 @@ def add_user(u): def update_user(u): #query_db("UPDATE users SET (NAME, LONGNAME, EMAIL, RFID_ID, ISBLACK, ISBARON, ISSHOWN) VALUES (?, ?, ?, ?, ?, ?, ?) WHERE ID=?", (u.name, u.longname, u.email, u.rfid_id, u.isblack, u.isbaron, u.isshown, u.id)) - query_db("UPDATE users SET NAME=?, PASSWORD=?, LONGNAME=?, EMAIL=?, RFID_ID=?, ISBLACK=?, ISBARON=?, ISSHOWN=? WHERE ID=?", (u.name, u.password, u.longname, u.email, u.rfid_id, u.isblack, u.isbaron, u.isshown, u.id)) + query_db("UPDATE users SET NAME=?, LONGNAME=?, EMAIL=?, RFID_ID=?, ISBLACK=?, ISBARON=?, ISSHOWN=? WHERE ID=?", (u.name, u.longname, u.email, u.rfid_id, u.isblack, u.isbaron, u.isshown, u.id)) get_db().commit() diff --git a/app/gui.py b/app/gui.py index e45cc79..0efca8c 100644 --- a/app/gui.py +++ b/app/gui.py @@ -2,8 +2,8 @@ import wx from plot import * from database import * - import flask as fla + class MainWindow(wx.Frame): def __init__(self, *args, **kwargs): @@ -42,13 +42,14 @@ class MainWindow(wx.Frame): self.switchPanels() def onUser(self, e): - self.active = 1 longn = e.GetEventObject().GetLabelText() for user in get_users(): if user.longname == longn: self.user = user - print self.user.id - print self.user.email + if not self.user.isblack: + self.active = 1 #getränkeauswahl + else: + self.active = 0 #start TODO: Sorry Bro Panel self.switchPanels() def onProduct(self, e): @@ -124,12 +125,13 @@ class Panel1 (wx.Panel): buttonids = [] i = 0 for product in products: - #480x320 - but = wx.Button(self, id=wx.ID_ANY, label=product.name + u"\n" + "%0.2f" % product.price, pos=(0+i*120, 0), size=(120, 120)) - but.SetFont(wx.Font(23, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans")) - print "Button %s created" % product.name - self.Bind(wx.EVT_BUTTON, parent.onProduct, id=but.Id) - i = i+1 + if product.isshown: + #480x320 + but = wx.Button(self, id=wx.ID_ANY, label=product.name + u"\n" + "%0.2f" % product.price, pos=(0+i*120, 0), size=(120, 120)) + but.SetFont(wx.Font(23, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans")) + print "Button %s created" % product.name + self.Bind(wx.EVT_BUTTON, parent.onProduct, id=but.Id) + i = i+1 self.b_less = wx.Button(self, id = wx.ID_ANY, label=u"-", pos=(0,240), size=(120, 80)) self.b_less.SetFont(wx.Font(60, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans")) @@ -178,18 +180,19 @@ class Panel2 (wx.Panel): users = get_users() names = list() for user in users: - names.append(user.longname) + if user.isshown: + names.append(user.longname) - i = 0 self.but_names = list() - for user in users: + i = 0 + for name in names: #480x320 - but = wx.Button(self, id=wx.ID_ANY, label=names[i], pos=(0,0+i*40), size=(400, 40)) + but = wx.Button(self, id=wx.ID_ANY, label=name, pos=(0,0+i*40), size=(400, 40)) but.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans")) self.Bind(wx.EVT_BUTTON, parent.onUser, id=but.Id) self.but_names.append(but) - i = i+1 + i += 1 b_up = wx.Button(self, id=wx.ID_ANY, label=u"\u25B2", pos=(400,0), size=(80, 80)) b_up.SetFont(wx.Font(20, wx.DEFAULT, wx.NORMAL, wx.NORMAL, 0, "Humor Sans")) diff --git a/app/templates/consume.html b/app/templates/consume.html index d7a0f0f..5c87026 100644 --- a/app/templates/consume.html +++ b/app/templates/consume.html @@ -10,9 +10,15 @@

{{ message }}

{% endif %}

- Möchtest du etwas konsumieren? - {% for product in products %} -

{{ product.id }}, {{product.name}} , {{"%0.2f" % product.price}} €

- {% endfor %} + {% if user.isblack %} + Sorry, du bist geschwärzt! + {% else %} + Möchtest du etwas konsumieren? + {% for product in products %} + {% if product.isshown %} +

{{ product.id }}, {{product.name}} , {{"%0.2f" % product.price}} €

+ {% endif %} + {% endfor %} + {% endif %}

{% endblock %} diff --git a/test/database.db b/test/database.db index f1b97b2aacdeac5a5122eb728318407e5da1592a..5726cc13fdffa4cc04a2fa9e0c08a76e444c3fd1 100644 GIT binary patch delta 147 zcmZoTz}#?vd4e?K#fdV`j2Aa1EM(_rzQMr4yqAIbEc09D2h4jnE3&L*cIIPYWsqg$ z@XId=&d4v%OW|Z>Wf0}$bjnOEVqjq40AdDiW>yACPEOy%?8LG}K_;L)JEu=(Zod7q qG%(o2lh4V>vAIB0gNc!I^GtDBW*~37RQG-$&-qp{3y62mlMw)xM<>$& delta 118 zcmZoTz}#?vd4e?KzKJrm{=G@*?lr|^X;FdfdL02P=wPdGqq?FPd+Cj=jH-Y4JJm8%`?SinSs3RQr-K3 OJm*`*EFj)JPeuUruOd4D