Development
This commit is contained in:
parent
c561f2f548
commit
1beb660be1
8 changed files with 280 additions and 48 deletions
|
|
@ -81,6 +81,76 @@ def _active_sessions_table():
|
|||
)
|
||||
|
||||
|
||||
def _accounts_table():
|
||||
accounts = config_utils.list_accounts()
|
||||
if not accounts:
|
||||
return '<p class="text-muted" style="margin:0">No accounts.</p>'
|
||||
|
||||
trs = ''
|
||||
for i, acct in enumerate(accounts):
|
||||
email = acct.get('email_address', '')
|
||||
req_email = acct.get('requested_email', '')
|
||||
acct_id = acct.get('account_id', '')
|
||||
level = acct.get('access_level', 'viewer')
|
||||
status = acct.get('account_status', 'pending')
|
||||
|
||||
if req_email:
|
||||
approve_btn = (
|
||||
f'<form method="post" action="/action/accountmanage/email_change_approve"'
|
||||
f' style="display:inline;margin:0">'
|
||||
f'<input type="hidden" name="account_id" value="{factory.e(acct_id)}">'
|
||||
f'<button type="submit" class="btn-link">Approve</button>'
|
||||
f'</form>'
|
||||
)
|
||||
deny_btn = (
|
||||
f'<form method="post" action="/action/accountmanage/email_change_deny"'
|
||||
f' style="display:inline;margin:0">'
|
||||
f'<input type="hidden" name="account_id" value="{factory.e(acct_id)}">'
|
||||
f'<button type="submit" class="btn-link btn-link-danger">Deny</button>'
|
||||
f'</form>'
|
||||
)
|
||||
email_cell = (
|
||||
f'{factory.e(email)}<br>'
|
||||
f'<span class="text-muted" style="font-size:0.85em">'
|
||||
f'{approve_btn} or {deny_btn} change to: {factory.e(req_email)}'
|
||||
f'</span>'
|
||||
)
|
||||
else:
|
||||
email_cell = factory.e(email)
|
||||
|
||||
row_json = factory.e(json.dumps({'email_address': email, 'access_level': level}))
|
||||
edit_btn = (
|
||||
f'<button type="button" class="btn btn-ghost btn-sm row-edit-btn"'
|
||||
f' data-row-index="{i}" data-row="{row_json}"'
|
||||
f' data-target="edit-form">Edit</button>'
|
||||
)
|
||||
delete_btn = (
|
||||
f'<form method="post" action="/action/accountmanage/accounts_delete"'
|
||||
f' class="form-inline">'
|
||||
f'<input type="hidden" name="row_index" value="{i}">'
|
||||
f'<button type="submit" class="btn btn-danger btn-sm">Delete</button>'
|
||||
f'</form>'
|
||||
)
|
||||
|
||||
trs += (
|
||||
f'<tr>'
|
||||
f'<td class="table-cell">{email_cell}</td>'
|
||||
f'<td class="table-cell">{factory.e(level)}</td>'
|
||||
f'<td class="table-cell">{factory.e(status)}</td>'
|
||||
f'<td class="col-actions">{edit_btn} {delete_btn}</td>'
|
||||
f'</tr>'
|
||||
)
|
||||
|
||||
return (
|
||||
'<table class="data-table"><thead><tr>'
|
||||
'<th class="table-header">Email</th>'
|
||||
'<th class="table-header">Access Level</th>'
|
||||
'<th class="table-header">Status</th>'
|
||||
'<th class="table-header"></th>'
|
||||
'</tr></thead><tbody>' + trs + '</tbody></table>'
|
||||
)
|
||||
|
||||
|
||||
def collect_tokens(cfg):
|
||||
tokens = config_utils.collect_layout_tokens(cfg)
|
||||
tokens['ACCOUNT_LEVEL_OPTIONS'] = json.dumps([
|
||||
|
|
@ -89,6 +159,7 @@ def collect_tokens(cfg):
|
|||
{'value': 'manager', 'label': 'Manager (full access including account management)'},
|
||||
])
|
||||
tokens['ACTIVE_SESSIONS_TABLE'] = _active_sessions_table()
|
||||
tokens['ACCOUNTS_TABLE'] = _accounts_table()
|
||||
content = factory.load_json(f'{factory.PAGES_DIR}/accountmanage/content.json')
|
||||
for table_item in factory.iter_table_items(content.get('items', [])):
|
||||
ds = table_item.get('datasource', '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue