Native gui: implement data lists for all modules
This commit is contained in:
@@ -14,7 +14,7 @@ Configuration file located at ~/.config/ymsgui.conf:
|
||||
pass = topsecret
|
||||
|
||||
[Documents]
|
||||
basepath = /var/local/yms
|
||||
basepath = /var/local/lib/yms
|
||||
|
||||
[Data]
|
||||
shapedir = /usr/local/share/yms/shapes
|
||||
@@ -39,6 +39,7 @@ from yms.model import user
|
||||
from yms.model import vessel
|
||||
|
||||
from yms.view.base import BaseView
|
||||
from yms.view.storage import StorageView
|
||||
from yms.view.equipment import EquipmentView
|
||||
from yms.view.inventory import InventoryView
|
||||
from yms.view.provisions import ProvisionsView
|
||||
@@ -57,6 +58,15 @@ class AppContext:
|
||||
'docpath': '/var/local/yms',
|
||||
'shapedir': '/usr/local/share/yms/shapes'
|
||||
}
|
||||
|
||||
# mapping between PHP and Python
|
||||
datefmt_map = {
|
||||
'Y-m-d': '%Y.%m.%d',
|
||||
'Y/m/d': '%Y/%m/%d',
|
||||
'd.m.Y': '%d.%m.%Y',
|
||||
'd/m/Y': '%d/%m/%Y',
|
||||
'm-d-Y': '%m.%d.%Y'
|
||||
}
|
||||
|
||||
def __init__(self):
|
||||
self.db = None
|
||||
@@ -64,6 +74,7 @@ class AppContext:
|
||||
self.vessel = None
|
||||
self.ui_path = os.path.join(self.get_sharepath(), "yms", "ui")
|
||||
self.textdomain = "ymsgui"
|
||||
self.datefmt = '%d.%m.%Y'
|
||||
|
||||
def set_db(self, db):
|
||||
self.db = db
|
||||
@@ -71,6 +82,19 @@ class AppContext:
|
||||
def load(self):
|
||||
self.user = user.User(db, 0)
|
||||
self.vessel = vessel.Vessel(db)
|
||||
# load date format from db settings
|
||||
sql = "SELECT valstr FROM settings WHERE userid=0 AND sno=2"
|
||||
self.db.cur.execute(sql)
|
||||
row = self.db.cur.fetchone()
|
||||
if row is not None:
|
||||
try:
|
||||
self.datefmt = self.datefmt_map[row[0]]
|
||||
except KeyError:
|
||||
# almost impossible case where db value is not in mapping
|
||||
print("internal error: format mapping missinf")
|
||||
else:
|
||||
# perhaps create missing record here?
|
||||
pass
|
||||
|
||||
def get_sharepath(self):
|
||||
path = os.path.realpath(__file__)
|
||||
@@ -85,6 +109,7 @@ class Frontend:
|
||||
def __init__(self, context):
|
||||
self.modules = {
|
||||
"base": BaseView(context),
|
||||
"storage": StorageView(context),
|
||||
"equipment": EquipmentView(context),
|
||||
"inventory": InventoryView(context),
|
||||
"provisions": ProvisionsView(context),
|
||||
|
||||
Reference in New Issue
Block a user