Add account views

This commit is contained in:
nemo 2024-04-29 10:13:55 +01:00
parent 8876b60481
commit 6eb992cb1b
2 changed files with 36 additions and 5 deletions

View File

@ -119,6 +119,7 @@
</table>
</div>
<h2>{% trans "Non Personal User Attributes" %}</h2>
<div class="table-responsive">
<table class="table table-striped" aria-describedby="uses table">
@ -137,7 +138,6 @@
<td>{{ attribute.value }}</td>
<td>{{ attribute.insert_date }}</td>
<td>
{# SuperAdmin has no entitlement_id! #}
{% if attribute.user_attribute_id %}
<form action="{% url 'users-delete-attribute' apiuser.user_id attribute.user_attribute_id %}" method="post">
{% csrf_token %}
@ -152,6 +152,26 @@
</tbody>
</table>
</div>
<h2>{% trans "Accounts Access" %}</h2>
<div class="table-responsive">
<table class="table table-striped" aria-describedby="uses table">
<thead>
<th scope="col">{% trans "Bank ID" %}</th>
<th scope="col">{% trans "Account ID" %}</th>
<th scope="col">{% trans "View ID" %}</th>
</thead>
<tbody>
{% for account in accounts_access.accounts %}
<tr>
<td>{{ account.bank_id }}</td>
<td>{{ account.account_id }}</td>
<td>{{ account.view_id }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>

View File

@ -189,10 +189,20 @@ class DetailView(LoginRequiredMixin, FormView):
try:
urlpath = '/users/{}/non-personal/attributes'.format(self.kwargs['user_id'])
non_personal_user_attributes = self.api.get(urlpath, settings.API_VERSION["v510"])
if 'code' in user and user['code']>=400:
messages.error(self.request, user['message'])
else:
context['form'].fields['user_id'].initial = user['user_id']
if 'code' in non_personal_user_attributes and non_personal_user_attributes['code']>=400:
messages.error(self.request, non_personal_user_attributes['message'])
except APIError as err:
messages.error(self.request, err)
except Exception as err:
messages.error(self.request, err)
accounts_access = {}
try:
urlpath = '/users/{}/account-access'.format(self.kwargs['user_id'])
accounts_access = self.api.get(urlpath, settings.API_VERSION["v510"])
print(accounts_access)
if 'code' in accounts_access and accounts_access['code']>=400:
messages.error(self.request, accounts_access['message'])
except APIError as err:
messages.error(self.request, err)
except Exception as err:
@ -201,6 +211,7 @@ class DetailView(LoginRequiredMixin, FormView):
context.update({
'apiuser': user, # 'user' is logged-in user in template context
'attributes': non_personal_user_attributes,
'accounts_access': accounts_access,
})
return context