Merge pull request #238 from Reena-cell/develop

little changes in Customer list
This commit is contained in:
Simon Redfern 2022-10-14 14:42:34 +02:00 committed by GitHub
commit 9f53886287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 9 deletions

View File

@ -10,7 +10,7 @@
<thead>
<th scope="col">{% trans "Customer Id" %}</th>
<th scope="col">{% trans "Bank Id" %}</th>
<th scope="col">{% trans "Customer Name" %}</th>
<th scope="col">{% trans "Legal Name" %}</th>
<th scope="col">{% trans "More info" %}</th>
</thead>
<tbody>

View File

@ -41,10 +41,9 @@ class CustomerListView(CreateView, LoginRequiredMixin, FormView ):
self.bankids = self.get_banks()
customers_list = []
#for bank_id in self.bankids:
urlpath = '/my/customers'
urlpath = '/customers'
#urlpath = 'http://127.0.0.1:8080/obp/v4.0.0/my/customers'
result = api.get(urlpath)
print(result, "Result is ")
if 'customers' in result:
customers_list.extend(result['customers'])
except APIError as err:
@ -53,17 +52,15 @@ class CustomerListView(CreateView, LoginRequiredMixin, FormView ):
except Exception as inst:
messages.error(self.request, "Unknown Error {}".format(type(inst).__name__))
return []
print(customers_list[0], "This is a customer list")
return customers_list
def get_context_data(self, **kwargs):
print("Hello from get_context_data")
context = super(CreateView, self).get_context_data(**kwargs)
customers_list = self.get_customers(context)
context.update({
'customers_list': customers_list,
'bankids': self.bankids
})
print(context, "Bye from get_context_data")
return context
class ExportCsvView(LoginRequiredMixin, View):
"""View to export the user to csv"""
@ -87,7 +84,6 @@ class ExportCsvView(LoginRequiredMixin, View):
for bank_id in self.bankids:
urlpath = '/banks/{}/customers'.format(bank_id)
result = api.get(urlpath)
#print(result)
if 'customers' in result:
customers_list.extend(result['customers'])
except APIError as err:
@ -95,7 +91,7 @@ class ExportCsvView(LoginRequiredMixin, View):
except Exception as inst:
messages.error(self.request, "Unknown Error {}".format(type(inst).__name__))
response = HttpResponse(content_type = 'text/csv')
response['Content-Disposition'] = 'attachment;filename= Atms'+ str(datetime.datetime.now())+'.csv'
response['Content-Disposition'] = 'attachment;filename= Customers'+ str(datetime.datetime.now())+'.csv'
writer = csv.writer(response)
writer.writerow(["bank_id","customer_id","customer_number","legal_name","mobile_phone_number","email","face_image", "url", "date", "date_of_birth","relationship_status", "dependants","dob_of_dependants","employment_status"])
for user in atms_list:
@ -103,5 +99,4 @@ class ExportCsvView(LoginRequiredMixin, View):
user["mobile_phone_number"], user["email"], user["face_image"]['url'], user["face_image"]['date'], user["date_of_birth"], user['relationship_status'], user["dependants"], user["dob_of_dependants"], user['employment_status']])
return response
#print(atms_list)