- add only buy with rfid option

This commit is contained in:
Ulrich Knechtelsdorfer
2016-07-01 17:03:23 +02:00
parent 042d0c86fa
commit 9f3ee93be9
8 changed files with 47 additions and 22 deletions

View File

@@ -52,10 +52,11 @@ def get_user(u):
u.password=row[2]
u.longname=row[3]
u.email=row[4]
u.isblack=row[6]
u.isbaron=row[7]
u.isshown=row[8]
u.autoblack=row[9]
u.isblack=row[5]
u.isbaron=row[6]
u.isshown=row[7]
u.autoblack=row[8]
u.onlyrfid=row[9]
u.rfid_id = get_rfid_ids_by_userid(u.id)
logging.info(u)
return u
@@ -70,10 +71,11 @@ def get_user_by_name(name):
u.password=row[2]
u.longname=row[3]
u.email=row[4]
u.isblack=row[6]
u.isbaron=row[7]
u.isshown=row[8]
u.autoblack=row[9]
u.isblack=row[5]
u.isbaron=row[6]
u.isshown=row[7]
u.autoblack=row[8]
u.onlyrfid=row[9]
logging.debug(u)
u.rfid_id = get_rfid_ids_by_userid(u.id)
return u
@@ -88,10 +90,11 @@ def get_user_by_id(id):
u.password=row[2]
u.longname=row[3]
u.email=row[4]
u.isblack=row[6]
u.isbaron=row[7]
u.isshown=row[8]
u.autoblack=row[9]
u.isblack=row[5]
u.isbaron=row[6]
u.isshown=row[7]
u.autoblack=row[8]
u.onlyrfid=row[9]
u.rfid_id = get_rfid_ids_by_userid(u.id)
logging.debug(u)
return u
@@ -114,10 +117,11 @@ def get_users():
u.password=row[2]
u.longname=row[3]
u.email=row[4]
u.isblack=row[6]
u.isbaron=row[7]
u.isshown=row[8]
u.autoblack=row[9]
u.isblack=row[5]
u.isbaron=row[6]
u.isshown=row[7]
u.autoblack=row[8]
u.onlyrfid=row[9]
u.rfid_id = get_rfid_ids_by_userid(u.id)
users.append(u)
return users
@@ -155,7 +159,7 @@ def add_rfid_id(rfid_id, userid):
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=?, LONGNAME=?, EMAIL=?, ISBLACK=?, ISBARON=?, ISSHOWN=?, AUTOBLACK=? WHERE ID=?", (u.name, u.longname, u.email, u.isblack, u.isbaron, u.isshown, u.autoblack, u.id))
query_db("UPDATE users SET NAME=?, LONGNAME=?, EMAIL=?, ISBLACK=?, ISBARON=?, ISSHOWN=?, AUTOBLACK=?, ONLYRFID=? WHERE ID=?", (u.name, u.longname, u.email, u.isblack, u.isbaron, u.isshown, u.autoblack, u.onlyrfid ,u.id))
set_rfid_to_userid(u.rfid_id, u.id)
get_db().commit()

View File

@@ -231,7 +231,7 @@ class PanelUsers (wx.Panel):
users = get_users()
names = list()
for user in users:
if user.isshown:
if user.isshown and not user.onlyrfid:
names.append(user.longname)
self.but_names = list()

View File

@@ -13,6 +13,7 @@
<th>Baron</th>
<th>Angezeigt</th>
<th>Auto-Schwärzen</th>
<th>Nur RFID Kreuzen</th>
<th></th>
</tr>
{% for user in users %}
@@ -26,6 +27,7 @@
<td>{% if user.isbaron %} &#9745; {% else %} &#9744; {% endif %} </td>
<td>{% if user.isshown %} &#9745; {% else %} &#9744; {% endif %} </td>
<td>{% if user.autoblack %} &#9745; {% else %} &#9744; {% endif %} </td>
<td>{% if user.onlyrfid %} &#9745; {% else %} &#9744; {% endif %} </td>
<td> <a href="/manage_users/edit/{{user.name}}">bearbeiten</a></td>
</tr>
{% endfor %}

View File

@@ -18,6 +18,7 @@
Baron: <input type="checkbox" name="isbaron" {% if user_to_edit.isbaron %} checked {% endif %} /> <br>
Angezeigt: <input type="checkbox" name="isshown" {% if user_to_edit.isshown %} checked {% endif %} /><br>
Auto-Schwärzen: <input type="checkbox" name="autoblack" {% if user_to_edit.autoblack %} checked {% endif %} /><br>
Nur mit RFID Kreuzen: <input type="checkbox" name="onlyrfid" {% if user_to_edit.onlyrfid %} checked {% endif %} /><br>
<input type="submit" value="Übernehmen" />
</form>
{% endif %}

View File

@@ -11,6 +11,7 @@ class User:
self.isbaron=False
self.isshown=False
self.autoblack=False
self.onlyrfid=False
def __str__(self):
@@ -72,7 +73,15 @@ class User:
if self.autoblack is None:
s = "%s, None" % s
else:
if self.isshown is 0 or self. isshown is False:
if self.autoblack is 0 or self. autoblack is False:
s = "%s, False" % s
else:
s = "%s, True" % s
if self.onlyrfid is None:
s = "%s, None" % s
else:
if self.onlyrfid is 0 or self. onlyrfid is False:
s = "%s, False" % s
else:
s = "%s, True" % s

View File

@@ -149,6 +149,10 @@ def manage_users_edit(name=None):
else:
u.autoblack = False
if 'onlyrfid' in request.form:
u.onlyrfid = True
else:
u.onlyrfid = False
update_user(u)

View File

@@ -36,11 +36,11 @@ CREATE TABLE Users(
password TEXT NOT NULL,
longname TEXT NOT NULL,
email TEXT,
rfid_id TEXT,
isblack BOOLEAN DEFAULT 0,
isbaron BOOLEAN DEFAULT 0,
isshown BOOLEAN DEFAULT 1,
autoblack BOOLEAN DEFAULT 1
autoblack BOOLEAN DEFAULT 1,
onlyrfid BOOLEAN DEFAULT 0
);
-- The table PRODUCTS contains information about the beverages available
@@ -76,7 +76,7 @@ CREATE TABLE Deposits(
);
CREATE TABLE Rfid(
di INTEGER PRIMARY KEY,
id INTEGER PRIMARY KEY,
userid INTEGER NOT NULL,
rfid_id TEXT,
is_valid BOOLEAN DEFAULT 1,
@@ -85,6 +85,11 @@ CREATE TABLE Rfid(
);
-- add one baron to login
INSERT INTO Users(name, password, longname, email, rfid_id, isblack, isbaron, isshown, onlyrfid) VALUES
(hindenburg, $2a$12$BGj0f9msFZiYqAN2DfKOme3lk1klMz1ea62IYNtLWz4q.zNXM0oR2, Paul von Hindenburg, hind@enburg.er, 0x6666666666, 0, 1, 1, 1, 0);
-- The table Config stores basic config data, this is for the admins and the barons

Binary file not shown.