From faac9d87acb2f3704191b53f49d9beee270b5ac8 Mon Sep 17 00:00:00 2001 From: Reena-cell Date: Fri, 14 Oct 2022 13:44:28 +0200 Subject: [PATCH] little changes in Customer list --- .../templates/customerlist/customerlist.html | 2 +- apimanager/customerlist/views.py | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/apimanager/customerlist/templates/customerlist/customerlist.html b/apimanager/customerlist/templates/customerlist/customerlist.html index a08b207..d46756a 100644 --- a/apimanager/customerlist/templates/customerlist/customerlist.html +++ b/apimanager/customerlist/templates/customerlist/customerlist.html @@ -10,7 +10,7 @@ {% trans "Customer Id" %} {% trans "Bank Id" %} - {% trans "Customer Name" %} + {% trans "Legal Name" %} {% trans "More info" %} diff --git a/apimanager/customerlist/views.py b/apimanager/customerlist/views.py index ad7acb1..3a8ebea 100644 --- a/apimanager/customerlist/views.py +++ b/apimanager/customerlist/views.py @@ -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)