Native gui first steps: storage, box and companies are editable
This commit is contained in:
1 parent
1eea4058bf
commit
06a9834688
47 files changed
+3119
-883
No files matched your search
+6
-5
@@ -1,5 +1,6 @@
|
||||
import MySQLdb
|
||||
import secrets
|
||||
from gettext import pgettext
|
||||
|
||||
class Database:
|
||||
|
||||
@@ -63,7 +64,6 @@ class Database:
|
||||
|
||||
def load_enum(self, table, column):
|
||||
"""
|
||||
TODO this is only an example! perhaps other keys needed
|
||||
Load an enum directly from a database table and provide it as a
|
||||
dictionary for use in, for example, selection lists.
|
||||
"""
|
||||
@@ -76,9 +76,10 @@ class Database:
|
||||
row = self.cur.fetchone()
|
||||
if not row:
|
||||
return {}
|
||||
enumvals = row[0].replace("'", "").split(",")
|
||||
return {
|
||||
i: _(value.strip("'"))
|
||||
for i, value in enumerate(row[0].split(','), 1)
|
||||
value: pgettext(f"{table}.{column}", value)
|
||||
for value in enumvals
|
||||
}
|
||||
|
||||
def lock_acquire(self, table, key, userid):
|
||||
@@ -94,7 +95,7 @@ class Database:
|
||||
return token
|
||||
except self.conn.IntegrityError as e:
|
||||
self.conn.rollback()
|
||||
if e.errno != 1062:
|
||||
if e.args[0] != 1062:
|
||||
raise
|
||||
# lazy locking: lock exists but is old, so we use it
|
||||
sql = (
|
||||
@@ -112,7 +113,7 @@ class Database:
|
||||
def lock_refresh(self, token):
|
||||
sql = (
|
||||
"UPDATE recordlock "
|
||||
"SET last_seen=current_timestamp() "
|
||||
"SET last_seen=CURRENT_TIMESTAMP "
|
||||
"WHERE token=%s"
|
||||
)
|
||||
self.cur.execute(sql, (token,))
|
||||
|
||||
Reference in new issue
Block a user