Check for missing key shortcuts

merge-requests/30/head
Bob Mottram 2021-04-23 18:29:18 +01:00
parent ce27c316e4
commit b7d09ef8ec
2 changed files with 8 additions and 3 deletions

View File

@ -14850,7 +14850,7 @@ def runDaemon(brochMode: bool,
'Reminder': 'r'
}
httpd.keyShortcuts = {}
loadAccessKeysForAccounts(baseDir, httpd.keyShortcuts)
loadAccessKeysForAccounts(baseDir, httpd.keyShortcuts, httpd.accessKeys)
httpd.unitTest = unitTest
httpd.allowLocalNetworkAccess = allowLocalNetworkAccess

View File

@ -13,7 +13,8 @@ from webapp_utils import htmlHeaderWithExternalStyle
from webapp_utils import htmlFooter
def loadAccessKeysForAccounts(baseDir: str, keyShortcuts: {}) -> None:
def loadAccessKeysForAccounts(baseDir: str, keyShortcuts: {},
accessKeysTemplate: {}) -> None:
"""Loads key shortcuts for each account
"""
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
@ -29,7 +30,11 @@ def loadAccessKeysForAccounts(baseDir: str, keyShortcuts: {}) -> None:
nickname = acct.split('@')[0]
accessKeys = loadJson(accessKeysFilename)
if accessKeys:
keyShortcuts[nickname] = accessKeys
keyShortcuts[nickname] = accessKeysTemplate.copy()
for variableName, key in accessKeysTemplate.items():
if accessKeys.get(variableName):
keyShortcuts[nickname][variableName] = \
accessKeys[variableName]
break