mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 18:06:45 +00:00
Merge pull request #130 from hongwei1/master
bugfix/remove the Secret Key
This commit is contained in:
commit
f76056a621
@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div id="create-invitation">
|
||||
<div id="user-invitation">
|
||||
<h1>Invite Developer</h1>
|
||||
|
||||
<form action="{% url 'my-user-invitation' %}" method="post">
|
||||
@ -71,6 +71,32 @@
|
||||
</div>
|
||||
|
||||
<input type="submit" value="Create" class="btn btn-primary" />
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover tablesorter" id="invitation-list">
|
||||
<thead>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Email</th>
|
||||
<th>company</th>
|
||||
<th>country</th>
|
||||
<th>purpose</th>
|
||||
<th>status</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for invitation in invitations %}
|
||||
<tr>
|
||||
<td>{{ invitation.first_name }}</td>
|
||||
<td>{{ invitation.last_name }}</td>
|
||||
<td>{{ invitation.email }}</td>
|
||||
<td>{{ invitation.company }}</td>
|
||||
<td>{{ invitation.country }}</td>
|
||||
<td>{{ invitation.purpose }}</td>
|
||||
<td>{{ invitation.status }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
@ -274,9 +274,11 @@ class InvitationView(LoginRequiredMixin, FormView):
|
||||
messages.error(self.request, "Unknown Error")
|
||||
return form
|
||||
|
||||
def form_valid(self, form):
|
||||
def form_valid(self, form, **kwargs):
|
||||
data = form.cleaned_data
|
||||
urlpath = '/banks/{}/user-invitation'.format(data['bank_id'])
|
||||
post_url_path = '/banks/{}/user-invitation'.format(data['bank_id'])
|
||||
get_url_path = '/banks/{}/user-invitations'.format(data['bank_id'])
|
||||
invitations=[]
|
||||
payload = {
|
||||
'first_name': data['first_name'],
|
||||
'last_name': data['last_name'],
|
||||
@ -285,20 +287,29 @@ class InvitationView(LoginRequiredMixin, FormView):
|
||||
'country': data['country'],
|
||||
'purpose': data['purpose']
|
||||
}
|
||||
context = self.get_context_data(**kwargs)
|
||||
try:
|
||||
result = self.api.post(urlpath, payload=payload)
|
||||
response = self.api.get(get_url_path)
|
||||
if 'code' in response and response['code'] >= 400:
|
||||
messages.error(self.request, response['message'])
|
||||
else:
|
||||
invitations = invitations + response['user_invitations']
|
||||
result = self.api.post(post_url_path, payload=payload)
|
||||
if 'code' in result and result['code'] >= 400:
|
||||
messages.error(self.request, result['message'])
|
||||
return super(InvitationView, self).form_valid(form)
|
||||
else:
|
||||
msg = 'Create User Invitation secret_key({}) at Bank({}) has been {}!'.format(result['secret_key'],data['bank_id'], result['status'] )
|
||||
context.update({
|
||||
'invitations': invitations,
|
||||
})
|
||||
msg = 'User Invitation ({}) at Bank({}) has been {}!'.format(result['first_name'],data['bank_id'], result['status'] )
|
||||
messages.success(self.request, msg)
|
||||
return super(InvitationView, self).form_valid(form)
|
||||
return self.render_to_response(context)
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
return super(InvitationView, self).form_invalid(form)
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, "Unknown Error:{}".format(str(err)))
|
||||
return super(InvitationView, self).form_invalid(form)
|
||||
|
||||
class DeleteEntitlementView(LoginRequiredMixin, View):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user