Skip to content

Commit

Permalink
Merge pull request #356 from nemozak1/develop
Browse files Browse the repository at this point in the history
Add account views to user
  • Loading branch information
simonredfern committed Jun 18, 2024
2 parents a62da42 + 6eb992c commit 212b609
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
22 changes: 21 additions & 1 deletion apimanager/users/templates/users/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ <h2>{% trans "Entitlements" %}</h2>
</table>
</div>


<h2>{% trans "Non Personal User Attributes" %}</h2>
<div class="table-responsive">
<table class="table table-striped" aria-describedby="uses table">
Expand All @@ -137,7 +138,6 @@ <h2>{% trans "Non Personal User Attributes" %}</h2>
<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 %}
Expand All @@ -152,6 +152,26 @@ <h2>{% trans "Non Personal User Attributes" %}</h2>
</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>
Expand Down
19 changes: 15 additions & 4 deletions apimanager/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,20 @@ def get_context_data(self, **kwargs):
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:
Expand All @@ -201,6 +211,7 @@ def get_context_data(self, **kwargs):
context.update({
'apiuser': user, # 'user' is logged-in user in template context
'attributes': non_personal_user_attributes,
'accounts_access': accounts_access,
})
return context

Expand Down

0 comments on commit 212b609

Please sign in to comment.