def get(self, request, *args, **kwargs): agent_id = kwargs['agent_id'] permissions = check_permission_agent_management(self) if not permissions['CAN_ACCESS_SHOP_MANAGEMENT_TAB']: return redirect('agents:agent_management_summary', agent_id=int(agent_id)) context = {"agent_id": agent_id, "permissions": permissions} opening_page_index = request.GET.get('current_page_index', 1) params = { "agent_id": agent_id, "paging": True, "page_index": int(opening_page_index) } shops = search_shop(self, params) page = shops.get('page', {}) context.update({ 'shops': shops.get('shops', []), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'total_result': page.get('total_elements', 0) }) return render(request, self.template_name, context)
def get_context_data(self, **kwargs): context = super(ListView, self).get_context_data(**kwargs) self.logger.info('========== Start get Service Group List ==========') self.initSearchDateTime(context) body = { 'is_deleted': False, 'paging': True, 'page_index': 1 } data, is_success = self.get_service_group_list(body) self.logger.info('========== Finished get Service Group List ==========') if is_success: page = data.get("page", {}) context.update({ 'data': data.get('service_groups'), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'search_count': page.get('total_elements', 0), 'is_show_export': check_permissions_by_user(self.request.user, 'CAN_EXPORT_SERVICE_GROUP') }) else: context.update({ 'data': [], 'is_show_export': False }) return context
def get(self, request, *args, **kwargs): permissions = {} permissions['CAN_ADD_SHOP'] = self.check_membership(["CAN_ADD_SHOP"]) permissions['CAN_EDIT_SHOP'] = self.check_membership(["CAN_EDIT_SHOP"]) permissions['CAN_DELETE_SHOP'] = self.check_membership( ["CAN_DELETE_SHOP"]) permissions['CAN_VIEW_SHOP'] = self.check_membership(["CAN_VIEW_SHOP"]) form = request.GET context = {"form": form} self.logger.info('========== Start getting all shop types ==========') list_shop_type = get_all_shop_type(self) self.logger.info('========== Finish getting all shop types ==========') context['list_shop_type'] = list_shop_type self.logger.info( '========== Start getting all shop categories ==========') list_shop_category = get_all_shop_category(self) self.logger.info( '========== Finish getting all shop categories ==========') context['list_shop_category'] = list_shop_category opening_page_index = form.get('current_page_index', 1) params = {"paging": True, "page_index": int(opening_page_index)} if form.get('shop_id'): params['id'] = int(form['shop_id']) if form.get('shop_category'): params['shop_category_id'] = int(form['shop_category']) if form.get('shop_name'): params['name'] = form['shop_name'] if form.get('shop_type'): params['shop_type_id'] = int(form['shop_type']) if form.get('relationship_manager'): params['relationship_manager_name'] = form['relationship_manager'] if form.get('owner_id'): params['agent_id'] = form['owner_id'] if form.get('mobile_device_unique_reference'): params['mobile_device_unique_reference'] = form[ 'mobile_device_unique_reference'] if form.get('edc_serial_number'): params['edc_serial_number'] = form['edc_serial_number'] shops = search_shop(self, params) page = shops.get('page', {}) context['permissions'] = permissions context.update({ 'shops': shops.get('shops', []), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'total_result': page.get('total_elements', 0) }) return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): self.logger.info( '========== Start searching bank SOF transaction ==========') sof_id = request.POST.get('sof_id') order_id = request.POST.get('order_id') status = request.POST.get('status') type = request.POST.get('type') from_created_timestamp = request.POST.get('from_created_timestamp') to_created_timestamp = request.POST.get('to_created_timestamp') opening_page_index = request.POST.get('current_page_index') body = self.createSearchBody(from_created_timestamp, order_id, sof_id, status, to_created_timestamp, type) body['paging'] = True body['page_index'] = int(opening_page_index) context = {} data, success, status_message = self._get_sof_bank_transaction( body=body) body['from_created_timestamp'] = from_created_timestamp body['to_created_timestamp'] = to_created_timestamp if success: cards_list = data.get("bank_sof_transactions", []) page = data.get("page", {}) self.logger.info("Page: {}".format(page)) context.update({ 'search_count': page.get('total_elements', 0), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), #'user_id': user_id, 'transaction_list': cards_list, 'search_by': body, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp }) else: context.update({ 'search_count': 0, 'paginator': {}, # 'user_id': user_id, 'transaction_list': [], 'search_by': body, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp }) self.logger.info( '========== Start searching bank SOF transaction ==========') return render(request, self.template_name, context)
def get_context_data(self, **kwargs): context = {} params = {'paging': True, 'page_index': 1} # Search with default status is activated - '1' params['status'] = 1 permissions = { 'CAN_VIEW_SERVICE': check_permissions_by_user(self.request.user, 'CAN_VIEW_SERVICE'), 'CAN_EDIT_SERVICE': check_permissions_by_user(self.request.user, 'CAN_EDIT_SERVICE'), 'CAN_EDIT_COMMAND_SERVICE': check_permissions_by_user(self.request.user, 'CAN_EDIT_COMMAND_SERVICE'), 'CAN_DELETE_SERVICE': check_permissions_by_user(self.request.user, 'CAN_DELETE_SERVICE'), 'CAN_ADD_SERVICE': check_permissions_by_user(self.request.user, 'CAN_ADD_SERVICE') } success, data = self.get_services_list(params) if not success: context['data'] = [] context['service_groups'] = [] context['search_count'] = 0 context['permissions'] = permissions context['is_show_export'] = False return context else: service_list = data.get('services') if success else [] page = data.get("page", {}) context['search_count'] = page.get('total_elements', 0) service_group_list = self.get_service_group_list() service_groups = [] for i in service_list: for j in service_group_list: if i['service_group_id'] == j['service_group_id']: i['service_group_name'] = j['service_group_name'] break for i in service_group_list: service_groups.append({ 'id': str(i['service_group_id']), 'name': i['service_group_name'] }) context['paginator'] = page context['page_range'] = calculate_page_range_from_page_info(page) context['data'] = service_list context['service_groups'] = service_groups context['permissions'] = permissions context['is_show_export'] = check_permissions_by_user( self.request.user, 'CAN_EXPORT_SERVICE') return context
def post(self, request, *args, **kwargs): user_id = request.POST.get('user_id') user_type_id = request.POST.get('user_type_id') currency = request.POST.get('currency') opening_page_index = request.POST.get('current_page_index') body = {} if user_id is not '': body['user_id'] = user_id if user_type_id is not '' and user_type_id is not '0': body['user_type'] = int(0 if user_type_id is None else user_type_id) if currency is not '': body['currency'] = currency if 'download' in request.POST: self.logger.info('========== Start export cash source of fund ==========') file_type = request.POST.get('export-type') body['file_type'] = file_type body['row_number'] = 5000 is_success, data = export_file(self, body=body, url_download=CASH_SOFS_URL, api_logger=API_Logger) if is_success: response = make_download_file(data, file_type) self.logger.info('========== End export cash source of fund ==========') return response else: self.logger.info('========== Start search cash source of fund ==========') data, success = self.get_cash_sof_list(body, opening_page_index) if not success: context = { 'sof_list': [], 'user_id': user_id, 'user_type_id': user_type_id, 'currency': currency, 'search_count': 0, 'is_show_export': False } return render(request, self.template_name, context) else: if data is not None: data = self.format_data(data) result_data = data.get('cash_sofs', []) page = data.get("page", {}) self.logger.info('Page: {}'.format(page)) context = { 'sof_list': result_data, 'user_id': user_id, 'user_type_id': user_type_id, 'currency': currency, 'search_count': page.get('total_elements', 0), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'is_show_export': check_permissions_by_user(self.request.user,"CAN_EXPORT_CASH_SOF_INFORMATION") } self.logger.info('========== End search cash source of fund ==========') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): request_id = request.POST.get('request_id') requested_by = request.POST.get('requested_by') request_action = request.POST.get('request_action') request_status = request.POST.get('request_status') original_voucher_id = request.POST.get('original_voucher_id') from_date = request.POST.get('requested_date_from') to_date = request.POST.get('requested_date_to') opening_page_index = request.POST.get('current_page_index') body = {} body['page_index'] = int(opening_page_index) if request_id != '': body['id'] = request_id if requested_by: body['requested_username'] = requested_by if request_status: body['status_id'] = int(request_status) if original_voucher_id: body['original_voucher_id'] = original_voucher_id if from_date: new_from_created_timestamp = datetime.strptime(from_date, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') body['from_created_timestamp'] = new_from_created_timestamp if to_date: new_to_created_timestamp = datetime.strptime(to_date, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace(hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') body['to_created_timestamp'] = new_to_created_timestamp self.logger.info('========== Start searching Voucher Adjustment ==========') data = self._search_for_vouchers(body) self.logger.info('========== Finished searching Voucher Adjustment ==========') page = data['page'] context = { 'data': self._format_data(data['refund_vouchers']), 'paginator': page, 'search_count': page['total_elements'], 'page_range': calculate_page_range_from_page_info(page), 'request_status_list': self._get_status_list(), 'request_action_list': self._get_requested_action_list(), 'request_id': request_id, 'requested_by': requested_by, 'selected_action': request_action, 'selected_status': request_status, 'original_voucher_id': original_voucher_id, 'requested_date_from': from_date, 'requested_date_to': to_date } return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): self.logger.info('========== Start search card profile ==========') card_identifier = request.POST.get('card_identifier') card_token = request.POST.get('card_token') user_id = request.POST.get('user_id') user_type = request.POST.get('user_type') opening_page_index = request.POST.get('current_page_index') body = {} body['paging'] = True body['page_index'] = int(opening_page_index) if card_identifier is not '' and card_identifier is not None: body['card_identifier'] = card_identifier if card_token is not '' and card_token is not None: body['token'] = card_token if user_id is not '' and user_id is not None: body['user_id'] = int(0 if user_id is None else user_id) if user_type is not '' and user_type is not '0': body['user_type_id'] = int(0 if user_type is None else user_type) context = {} data, success, status_message = self.get_card_list(body) if success: cards_list = data.get("cards", []) if cards_list is not None: cards_list = self.format_data(cards_list) page = data.get("page", {}) self.logger.info("Page: {}".format(page)) context.update( {'search_count': page.get('total_elements', 0), 'data': cards_list, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'card_identifier': card_identifier, 'card_token': card_token, 'user_id': user_id, 'user_type': user_type,} ) else: context.update( {'search_count': 0, 'data': [], 'paginator': {}, 'card_identifier': card_identifier, 'card_token': card_token, 'user_id': user_id, 'user_type': user_type, } ) self.logger.info('========== End search card profile ==========') return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): context = super(ShopTypeList, self).get_context_data(**kwargs) body = {"paging": True, "page_index": 1} shop_types = self.get_shop_type(body) page = shop_types.get("page", {}) context.update({ 'shop_types': shop_types['shop_types'], 'paginator': page, 'page_range': calculate_page_range_from_page_info(page) }) return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): self.logger.info('========== Start search history card ==========') trans_id = request.GET.get('trans_id') card_id = request.GET.get('card_id') user_id = request.GET.get('user_id') user_type_id = request.GET.get('user_type_id') if (trans_id, card_id, user_id, user_type_id) == (None, None, None, None): result_data = {} page = {'total_pages': 1, 'current_page': 1} else: body = { 'paging': True, 'page_index': int(request.GET.get('current_page_index')) } if trans_id is not '': body['trans_id'] = trans_id if card_id is not '': body['card_id'] = int(0 if card_id is None else card_id) if user_id is not '': body['user_id'] = int(0 if user_id is None else user_id) if user_type_id is not '' and user_type_id is not '0': body['user_type_id'] = int( 0 if user_type_id is None else user_type_id) data = self.get_card_history_list(body) page = data.get("page", {}) self.logger.info('Page: {}'.format(page)) data = data.get('card_histories', []) if data is not None: result_data = self.format_data(data) else: result_data = data context = { 'data': result_data, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'trans_id': "" if trans_id is None else trans_id, 'card_id': str("" if card_id is None else card_id), 'user_id': str("" if user_id is None else user_id), 'user_type_id': user_type_id } self.logger.info('========== End search card history ==========') return render(request, 'history.html', context)
def get(self, request, *args, **kwargs): context = super(ListView, self).get_context_data(**kwargs) is_deleted_status_list = [{ "value": "0", "name": "No" }, { "value": "1", "name": "Yes" }, { "value": "", "name": "All" }] context.update({'is_deleted_status_list': is_deleted_status_list}) opening_page_index = request.GET.get('current_page_index', 1) service_id = request.GET.get('service_id', "") service_name = request.GET.get('service_name', "") is_deleted = request.GET.get('is_deleted', "0") params = {} params['paging'] = True params['page_index'] = int(opening_page_index) if service_id: params['id'] = service_id if service_name: params['name'] = service_name if is_deleted: params['is_deleted'] = True if is_deleted == '1' else False channel_service_list = self.get_service_list(params) page = channel_service_list.get('page', {}) context.update({ 'channel_service_list': channel_service_list.get('services', []), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'total_result': page.get('total_elements', 0), "service_id": service_id, "selected_deleted_status": is_deleted, "service_name": service_name }) return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): self.logger.info( '========== Start pagination customer bank SOF ==========') user_id = request.POST.get('user_id') opening_page_index = request.POST.get('current_page_index') body = {} body['paging'] = True body['page_index'] = int(opening_page_index) if user_id is not '' and user_id is not None: body['user_id'] = user_id context = {} data, success, status_message = self._get_bank_sof_list(body=body) body['user_type_id'] = UserType.CUSTOMER.value if success: cards_list = data.get("bank_sofs", []) page = data.get("page", {}) self.logger.info("Page: {}".format(page)) context.update({ 'search_count': page.get('total_elements', 0), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'user_id': user_id, 'bank_sof_list': cards_list, 'search_by': body }) else: context.update({ 'search_count': 0, 'paginator': {}, 'user_id': user_id, 'bank_sof_list': [], 'search_by': body }) self.logger.info( '========== End pagination customer bank SOF ==========') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): context = super(ShopTypeList, self).get_context_data(**kwargs) opening_page_index = request.POST.get('current_page_index') body = {} body['paging'] = True body['page_index'] = int(opening_page_index) shop_types = self.get_shop_type(body) page = shop_types.get("page", {}) context.update({ 'shop_types': shop_types['shop_types'], 'paginator': page, 'page_range': calculate_page_range_from_page_info(page) }) return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): self.logger.info( '========== Start getting customer sof bank ==========') user_id = int(kwargs.get('customerId')) self.logger.info('API-Path: {};'.format(self.searchcustomerbanksofurl)) param = {"user_id": user_id, "user_type_id": UserType.CUSTOMER.value} data, success = self._post_method( api_path=self.searchcustomerbanksofurl, func_description="member customer detail", logger=logger, params=param) context = {} if success: cards_list = data.get("bank_sofs", []) page = data.get("page", {}) self.logger.info("Page: {}".format(page)) context.update({ 'search_count': page.get('total_elements', 0), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'bank_sof_list': cards_list, 'user_id': user_id, }) else: context.update({ 'search_count': 0, 'paginator': {}, 'user_id': user_id, 'bank_sof_list': [], }) self.logger.info( '========== Finished searching customer sof ==========') return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): context = super(OTPList, self).get_context_data(**kwargs) self.logger.info('========== Start getting otp list ==========') self.initSearchDateTime(context) body= {'paging': True, 'page_index': 1} otp_list, is_success = self.get_otp_list(body) page = otp_list.get("page", {}) context.update({ 'delivery_channel': 'All', 'user_type': 'All', 'is_success_verified': 'All', 'otp_list': otp_list['otps'], 'paginator': page, 'search_count': page.get('total_elements', 0), 'page_range': calculate_page_range_from_page_info(page), }) self.logger.info('========== Finish getting otp list ==========') return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): context = super(ListTrust, self).get_context_data(**kwargs) body = { "paging": True, "page_index": 1, "is_deleted": False, "is_expired": False } trust_role = request.GET.get('trust_role') if trust_role and trust_role != "all": body['role'] = trust_role context['trust_role'] = trust_role user_id = request.GET.get('user_id') if user_id and user_id != '': body['user_id'] = user_id context['user_id'] = user_id user_type = request.GET.get('user_type') if user_type and user_type != "all": body['user_type_id'] = user_type context['user_type'] = user_type opening_page_index = request.GET.get('current_page_index') if opening_page_index: body['page_index'] = int(opening_page_index) context['current_page_index'] = int(opening_page_index) success, trusts = self.get_trust_list(body) if success: page = trusts.get("page", {}) context.update({ 'trusts': trusts.get('token_information'), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page) }) else: messages.error(request, trusts) return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): self.logger.info('========== Start getting user list ==========') context = super(UserList, self).get_context_data(**kwargs) mobile_number = request.GET.get('mobile_number') opening_page_index = request.GET.get('current_page_index') body = { 'paging': True, 'page_index': int(opening_page_index), 'mobile_number': mobile_number } is_success, status_code, status_message, data = self.search_user_list( body=body) if is_success: page = data.get("page", {}) user_list = data['users'] total_elements = page.get('total_elements', 0) if total_elements == 0: return JsonResponse({'no_record': 'true'}) elif total_elements == 1: user = data['users'][0] return JsonResponse(user) else: page_range = calculate_page_range_from_page_info(page) context.update({ 'user_list': user_list, 'paginator': page, 'search_count': page.get('total_elements', 0), 'page_range': page_range }) self.logger.info('========== End getting user list ==========') return render(request, "payments/user_list.html", context) else: if status_code == 'Timeout': return HttpResponse(status=504) return HttpResponse(status=500)
def post(self, request, *args, **kwargs): context = super(ListView, self).get_context_data(**kwargs) self.logger.info('========== Start {} service groups list =========='.format("downloading" if 'download' in request.POST else "searching")) service_group_id = request.POST.get('service_group_id') service_group_name = request.POST.get('service_group_name') created_from_date = request.POST.get('created_from_date') created_to_date = request.POST.get('created_to_date') created_from_time = request.POST.get('created_from_time') created_to_time = request.POST.get('created_to_time') modified_from_date = request.POST.get('modified_from_date') modified_to_date = request.POST.get('modified_to_date') modified_from_time = request.POST.get('modified_from_time') modified_to_time = request.POST.get('modified_to_time') opening_page_index = request.POST.get('current_page_index') body = {'is_deleted': False} if service_group_id: body['service_group_id'] = service_group_id if service_group_name: body['service_group_name'] = service_group_name if created_from_date: body['from_created_timestamp'] = convert_string_to_date_time(created_from_date, created_from_time) if created_to_date: body['to_created_timestamp'] = convert_string_to_date_time(created_to_date, created_to_time) if modified_from_date: body['from_last_updated_timestamp'] = convert_string_to_date_time(modified_from_date, modified_from_time) if modified_to_date: body['to_last_updated_timestamp'] = convert_string_to_date_time(modified_to_date, modified_to_time) if 'download' in request.POST: file_type = request.POST.get('export-type') body['file_type'] = file_type body['row_number'] = 5000 is_success, data = export_file(self, body=body, url_download=api_settings.SERVICE_GROUP_LIST_PATH, api_logger=API_Logger) if is_success: response = make_download_file(data, file_type) self.logger.info('========== Finish exporting payment service ==========') return response else: body['paging'] = True body['page_index'] = int(opening_page_index) data, is_success = self.get_service_group_list(body) context.update({ 'service_group_id': service_group_id, 'service_group_name': service_group_name, 'created_from_date': created_from_date, 'created_to_date': created_to_date, 'created_from_time': created_from_time, 'created_to_time': created_to_time, 'modified_from_date': modified_from_date, 'modified_to_date': modified_to_date, 'modified_from_time': modified_from_time, 'modified_to_time': modified_to_time, }) if is_success: page = data.get("page", {}) context.update({ 'search_count': page.get('total_elements', 0), 'data': data['service_groups'], 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'is_show_export': check_permissions_by_user(self.request.user, 'CAN_EXPORT_SERVICE_GROUP') }) else: context.update({ 'data': [], 'is_show_export': False }) self.logger.info('========== Finish searching service groups list ==========') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): params = {} context = {} name = request.POST.get('name') id = request.POST.get('id') currency = request.POST.get('currency') group = request.POST.get('group') status = request.POST.get('status') opening_page_index = request.POST.get('current_page_index') if id: context['id'] = id params['id'] = id if name: context['name'] = name params['service_name'] = name if currency: context['currency'] = currency params['currency'] = currency if group: context['group'] = group params['service_group_id'] = group if not status: params['status'] = 1 else: context['status'] = status if status in ['0', '1']: params['status'] = int(status) if 'download' in request.POST: self.logger.info( '========== Start exporting payment service ==========') file_type = request.POST.get('export-type') params['file_type'] = file_type params['row_number'] = 5000 is_success, data = export_file(self, body=params, url_download=SEARCH_SERVICE, api_logger=API_Logger) if is_success: response = make_download_file(data, file_type) self.logger.info( '========== Finish exporting payment service ==========') return response else: params['paging'] = True if opening_page_index: params['page_index'] = int(opening_page_index) context['current_page_index'] = int(opening_page_index) else: params['page_index'] = 1 permissions = { 'CAN_VIEW_SERVICE': check_permissions_by_user(self.request.user, 'CAN_VIEW_SERVICE'), 'CAN_EDIT_SERVICE': check_permissions_by_user(self.request.user, 'CAN_EDIT_SERVICE'), 'CAN_EDIT_COMMAND_SERVICE': check_permissions_by_user(self.request.user, 'CAN_EDIT_COMMAND_SERVICE'), 'CAN_DELETE_SERVICE': check_permissions_by_user(self.request.user, 'CAN_DELETE_SERVICE'), 'CAN_ADD_SERVICE': check_permissions_by_user(self.request.user, 'CAN_ADD_SERVICE') } success, data = self.get_services_list(params) if not success: context['data'] = [] context['service_groups'] = [] context['search_count'] = 0 context['permissions'] = permissions context['is_show_export'] = False return render(request, self.template_name, context) else: service_list = data.get('services') if success else [] page = data.get("page", {}) context['search_count'] = page.get('total_elements', 0) service_groups = [] if success: service_group_list = self.get_service_group_list() for i in service_list: for j in service_group_list: if i['service_group_id'] == j['service_group_id']: i['service_group_name'] = j[ 'service_group_name'] break for i in service_group_list: service_groups.append({ 'id': str(i['service_group_id']), 'name': i['service_group_name'] }) context['paginator'] = page context['page_range'] = calculate_page_range_from_page_info( page) context['data'] = service_list context['service_groups'] = service_groups context['permissions'] = permissions context['is_show_export'] = check_permissions_by_user( self.request.user, 'CAN_EXPORT_SERVICE') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): voucher_id = request.POST.get('voucher_id') claim_status = request.POST.get('claim_status') cash_in_id = request.POST.get('cash_in_id') cash_out_id = request.POST.get('cash_out_id') from_date = request.POST.get('create_date_from') to_date = request.POST.get('create_date_to') expire_from_date = request.POST.get('expiration_date_from') expire_to_date = request.POST.get('expiration_date_to') hold_status = request.POST.get('hold_status') cash_in_user_type = request.POST.get('user_type_cash_in') opening_page_index = request.POST.get('current_page_index') cash_in_order_id = request.POST.get('cash_in_order_id') cash_out_order_id = request.POST.get('cash_out_order_id') issuer_user_id = request.POST.get('issuer_user_id') cancel_status = request.POST.get('cancel_status') voucher_type = request.POST.get('voucher_type') distributed_status = request.POST.get('distributed_status') voucher_group = request.POST.get('voucher_group') body = {} body['page_index'] = int(opening_page_index) if cash_in_user_type != '': body['cash_in_user_type'] = cash_in_user_type if cash_in_id: body['cash_in_user_id'] = int(cash_in_id) if cash_out_id: body['cash_out_user_id'] = int(cash_out_id) if voucher_id: body['voucher_id'] = int(voucher_id) if claim_status == 'True': body['is_used'] = True if claim_status == 'False': body['is_used'] = False if hold_status != '': body['is_on_hold'] = True if hold_status == 'True' else False if cash_in_order_id: body['cash_in_order_id'] = int(cash_in_order_id) if cash_out_order_id: body['cash_out_order_id'] = int(cash_out_order_id) if issuer_user_id: body['issuer_user_id'] = int(issuer_user_id) if cancel_status != '': body['is_cancelled'] = True if cancel_status == 'True' else False if from_date: new_from_created_timestamp = datetime.strptime( from_date, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['from_created_timestamp'] = new_from_created_timestamp if to_date: new_to_created_timestamp = datetime.strptime(to_date, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace( hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['to_created_timestamp'] = new_to_created_timestamp if expire_from_date: new_expire_from_timestamp = datetime.strptime( expire_from_date, "%Y-%m-%d") new_expire_from_timestamp = new_expire_from_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['from_expire_date_timestamp'] = new_expire_from_timestamp if expire_to_date: new_to_expire_timestamp = datetime.strptime( expire_to_date, "%Y-%m-%d") new_to_expire_timestamp = new_to_expire_timestamp.replace( hour=23, minute=59, second=59) new_to_expire_timestamp = new_to_expire_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['to_expire_date_timestamp'] = new_to_expire_timestamp if voucher_type != '': body['voucher_type'] = voucher_type if distributed_status != '': body[ 'distributed_status'] = True if distributed_status == 'True' else False if voucher_group != '': body['voucher_group'] = voucher_group self.logger.info('========== Start searching Vouchers ==========') data = self._search_for_vouchers(body) self.logger.info('========== Finished searching Vouchers ==========') permissions = {} permissions['CAN_VIEW_VOUCHER_DETAILS'] = check_permissions_by_user( self.request.user, 'CAN_VIEW_VOUCHER_DETAILS') permissions['CAN_CREATE_VOUCHER_ACTION'] = check_permissions_by_user( self.request.user, 'CAN_CREATE_VOUCHER_ACTION') permissions['CAN_HOLD_VOUCHER_ACTION'] = self.check_membership( ['CAN_HOLD_VOUCHER_ACTION']) permissions['CAN_UNHOLD_VOUCHER_ACTION'] = self.check_membership( ['CAN_UNHOLD_VOUCHER_ACTION']) page = data['page'] context = { 'data': data['vouchers'], 'paginator': page, 'search_count': page['total_elements'], 'page_range': calculate_page_range_from_page_info(page), 'voucher_id': voucher_id, 'claim_status_list': self._get_status_list(), 'selected_status': claim_status, 'cash_in_id': cash_in_id, 'cash_out_id': cash_out_id, 'create_date_from': from_date, 'create_date_to': to_date, 'expiration_date_from': expire_from_date, 'expiration_date_to': expire_to_date, 'permissions': permissions, 'hold_status_list': self._get_hold_status_list(), 'hold_status': hold_status, 'cash_in_user_type_list': self._get_user_type_cash_in_list(), 'cash_in_user_type': cash_in_user_type, 'cancel_status_list': self._get_cancel_status_list(), 'cash_out_order_id': cash_out_order_id, 'cash_in_order_id': cash_in_order_id, 'issuer_user_id': issuer_user_id, 'cancel_status': cancel_status, 'voucher_type_list': self._get_voucher_type_list(), 'voucher_type': voucher_type, 'distributed_status_list': self._get_distributed_status_list(), 'distributed_status': distributed_status, 'voucher_group': voucher_group, } return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): self.logger.info( '========== Start getting customer transaction history ==========') context = super(TransactionHistoryView, self).get_context_data(**kwargs) user_id = context['customerId'] user_type = UserType.CUSTOMER.value choices = self._get_choices_types() cash_sof_list = self._get_cash_sof_list(user_id, user_type).get( 'cash_sofs', []) body = {} body['paging'] = True body['page_index'] = 1 request.session['page_from'] = 'customer' request.session['customer_id'] = user_id sof_id = request.GET.get('sof_id') sof_type_id = request.GET.get('sof_type_id') opening_page_index = request.GET.get('current_page_index') from_created_timestamp = request.GET.get('from_created_timestamp') to_created_timestamp = request.GET.get('to_created_timestamp') status_id = request.GET.get('status_id') if status_id is not '' and status_id is not None: status_id = int(status_id) if sof_id is None and sof_type_id is None and opening_page_index is None and from_created_timestamp is None and to_created_timestamp is None: # Set first load default time for Context from_created_timestamp = datetime.now() to_created_timestamp = datetime.now() from_created_timestamp = from_created_timestamp.replace(hour=0, minute=0, second=1) to_created_timestamp = to_created_timestamp.replace(hour=23, minute=59, second=59) new_from_created_timestamp = from_created_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") new_to_created_timestamp = to_created_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") body['from_created_timestamp'] = new_from_created_timestamp new_from_created_timestamp = from_created_timestamp.strftime( "%Y-%m-%d") context['from_created_timestamp'] = new_from_created_timestamp body['to_created_timestamp'] = new_to_created_timestamp new_to_created_timestamp = to_created_timestamp.strftime( "%Y-%m-%d") context['to_created_timestamp'] = new_to_created_timestamp body['sof_type_id'] = SOFType.CASH.value body['user_type_id'] = UserType.CUSTOMER.value body['user_id'] = user_id order_balance_movements, page, summaries, success = self._get_transaction_history( body) if success: if order_balance_movements is not None: result_data = self.format_data(order_balance_movements) has_permission_view_payment_order_detail = check_permissions_by_user( self.request.user, 'CAN_VIEW_PAYMENT_ORDER_DETAIL') for i in order_balance_movements: i['has_permission_view_payment_order_detail'] = has_permission_view_payment_order_detail else: result_data = order_balance_movements self.logger.info("Page: {}".format(page)) context.update({ 'search_count': page.get('total_elements', 0), 'list': result_data, 'summaries': summaries, 'choices': choices, 'cash_sof_list': cash_sof_list, 'status_list': status_list, 'status_id': status_id, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'user_id': user_id, 'is_show_export': check_permissions_by_user( self.request.user, 'CAN_EXPORT_CUSTOMER_INDIVIDUAL_WALLET') }) else: context.update({ 'search_count': 0, 'data': [], 'status_list': status_list, 'status_id': status_id, 'paginator': {}, 'user_id': user_id, 'is_show_export': False }) permissions = {} else: if sof_id is not '' and sof_id is not None: sof_id = int(sof_id) body['sof_id'] = sof_id if sof_type_id is not '' and sof_type_id is not None: body['sof_type_id'] = int(sof_type_id) body['user_type_id'] = UserType.CUSTOMER.value body['user_id'] = user_id if status_id is not '' and status_id is not None: body['status_id_list'] = [status_id] context = {} # validate required search date criteria if from_created_timestamp is '' or to_created_timestamp is '': messages.add_message( request, messages.ERROR, 'Please specify the to and from date search criteria') context.update({ 'search_count': 0, 'list': [], 'summaries': [], 'choices': choices, 'sof_type_id': sof_type_id, 'sof_id': sof_id, 'cash_sof_list': cash_sof_list, 'status_list': status_list, 'status_id': status_id, 'paginator': {}, 'user_id': user_id, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp }) return render(request, self.template_name, context) diffDay = self._getDiffDaysFromUIDateValue(from_created_timestamp, to_created_timestamp) # validate fromDate less than or equals to toDate if diffDay < 0: messages.add_message( request, messages.ERROR, 'The from date should be before or equal to the to date') context.update({ 'search_count': 0, 'list': [], 'summaries': [], 'choices': choices, 'sof_type_id': sof_type_id, 'sof_id': sof_id, 'cash_sof_list': cash_sof_list, 'status_list': status_list, 'status_id': status_id, 'paginator': {}, 'user_id': user_id, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp }) return render(request, self.template_name, context) # validate date range walletViewInDay = self._getWalletViewInDay() if diffDay > int(walletViewInDay): messages.add_message( request, messages.ERROR, 'Time range over ' + walletViewInDay + ' day(s) is not allowed') context.update({ 'search_count': 0, 'list': [], 'summaries': [], 'choices': choices, 'sof_type_id': sof_type_id, 'sof_id': sof_id, 'cash_sof_list': cash_sof_list, 'status_list': status_list, 'status_id': status_id, 'paginator': {}, 'user_id': user_id, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp }) return render(request, self.template_name, context) # build date range critera for service new_from_created_timestamp = datetime.strptime( from_created_timestamp, self.dateUIFormat) new_from_created_timestamp = new_from_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['from_created_timestamp'] = new_from_created_timestamp new_to_created_timestamp = datetime.strptime( to_created_timestamp, self.dateUIFormat) new_to_created_timestamp = new_to_created_timestamp.replace( hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['to_created_timestamp'] = new_to_created_timestamp if 'download' in request.GET: self.logger.info('Exporting customer transaction history') file_type = request.GET.get('export-type') body['file_type'] = file_type body['row_number'] = 5000 is_success, data = export_file( self, body=body, url_download=BALANCE_MOVEMENT_LIST_PATH, api_logger=API_Logger) if is_success: response = make_download_file(data, file_type) self.logger.info( 'Export customer transaction history success') return response if 'search' in request.GET: self.logger.info('Searching customer transaction history') order_balance_movements, page, summaries, success = self._get_transaction_history( body) if success: if order_balance_movements is not None: result_data = self.format_data(order_balance_movements) has_permission_view_payment_order_detail = check_permissions_by_user( self.request.user, 'CAN_VIEW_PAYMENT_ORDER_DETAIL') for i in order_balance_movements: i['has_permission_view_payment_order_detail'] = has_permission_view_payment_order_detail else: result_data = order_balance_movements self.logger.info("Page: {}".format(page)) context.update({ 'search_count': page.get('total_elements', 0), 'list': result_data, 'summaries': summaries, 'choices': choices, 'sof_type_id': sof_type_id, 'sof_id': sof_id, 'cash_sof_list': cash_sof_list, 'status_list': status_list, 'status_id': status_id, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'user_id': user_id, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp, 'is_show_export': check_permissions_by_user( self.request.user, 'CAN_EXPORT_CUSTOMER_INDIVIDUAL_WALLET') }) else: context.update({ 'search_count': 0, 'data': [], 'status_list': status_list, 'status_id': status_id, 'paginator': {}, 'user_id': user_id, 'is_show_export': False }) self.logger.info('Finish search customer transaction history') request.session['customer_redirect_from_wallet_view'] = True request.session['back_wallet_url'] = request.build_absolute_uri() self.logger.info( '========== Finished getting customer transaction history ==========' ) return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): self.logger.info('========== Start searching partner file list ==========') context = super(PartnerFileList, self).get_context_data(**kwargs) opening_page_index = request.POST.get('current_page_index') is_on_us = request.POST.get('on_off_us_id') service_group_id = request.POST.get('service_group_id') service_name = request.POST.get('service_name') agent_id = request.POST.get('partner_id') currency = request.POST.get('currency_id') reconcile_status = request.POST.get('reconcile_status_id') from_created_timestamp = request.POST.get('from_created_timestamp') to_created_timestamp = request.POST.get('to_created_timestamp') params = {} params['opening_page_index'] = opening_page_index is_on_us_id = int(is_on_us) reconcile_status_id = int(reconcile_status) if is_on_us_id >= 0: params['is_on_us'] = (is_on_us_id == 1) if service_name != '': if service_name == None: params['service_name'] = '' else: params['service_name'] = service_name if agent_id != '': params['agent_id'] = int(agent_id) if currency != '': params['currency'] = currency if reconcile_status_id >= 0: params['status_id'] = reconcile_status_id if from_created_timestamp is not '': new_from_created_timestamp = datetime.strptime(from_created_timestamp, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') params['from_last_updated_timestamp'] = new_from_created_timestamp if to_created_timestamp is not '': new_to_created_timestamp = datetime.strptime(to_created_timestamp, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace(hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') params['to_last_updated_timestamp'] = new_to_created_timestamp currencies, success = self._get_currency_choices() if success is True: context.update({'currencies': currencies}) services_list, service_groups, service_group_id, success = self._get_service_group_and_services_list( service_group_id) if success is True: context.update({'service_list': services_list, 'service_groups': service_groups, 'service_group_id': service_group_id}) else: context.update({'partner_file_list_error_msg': 'Fail to get service group, please refresh the page or contact technical support'}) params.pop('service_name','') try: data, page, status_code = self._search_file_list(params) if status_code == 500: self.logger.error('Search fail, please try again or contact technical support') context.update({'partner_file_list_error_msg': 'Search fail, please try again or contact technical support'}) else: context.update({'file_list': data, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page)}) except requests.Timeout: self.logger.error('Search partner file list request timeout') context.update({'partner_file_list_error_msg': 'Search timeout, please try again or contact technical support'}) context.update({'is_on_us': is_on_us_id, 'agent_id': agent_id, 'currency': currency, 'status_id': reconcile_status_id, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp, 'selected_service': service_name}) self.logger.info("========== Finish searching partner file list ==========") return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): permissions = {} permissions['CAN_ADD_PRODUCT'] = self.check_membership(["CAN_ADD_PRODUCT"]) permissions['CAN_EDIT_PRODUCT'] = self.check_membership(["CAN_EDIT_PRODUCT"]) permissions['CAN_DELETE_PRODUCT'] = self.check_membership(["CAN_DELETE_PRODUCT"]) permissions['CAN_VIEW_PRODUCT'] = self.check_membership(["CAN_VIEW_PRODUCT"]) params = {} products = {} is_success = False status_code = '' url = api_settings.GET_PRODUCTS context = super(ListView, self).get_context_data(**kwargs) categories = self._list_categories() if categories: categories.insert(0, {'name':'All'}) context['categories'] = categories else: context['categories'] = [{'name':'All'}] self.logger.info('========== Start searching products ==========') opening_page_index = request.GET.get('current_page_index') product_id = request.GET.get('product_id') category_id = request.GET.get('category_id') product_name = request.GET.get('product_name') product_status = request.GET.get('product_status') if product_id is None and category_id is None \ and product_name is None and product_status is None: products = {} context['search_count'] = 0 else: params['paging'] = True params['page_index'] = int(opening_page_index) if product_id: product_id = int(product_id) params['id'] = product_id context['product_id'] = product_id if category_id: category_id = int(category_id) params['product_category_id'] = category_id context['category_id'] = category_id if product_name: params['name'] = product_name context['product_name'] = product_name if product_status and isinstance(product_status, str): if product_status.lower() == "true": product_status = True else: product_status = False params['is_active'] = product_status context['product_status'] = product_status params['is_deleted'] = False is_success, status_code, status_message, data = RestFulClient.post( url= url, headers=self._get_headers(), loggers=self.logger, params=params) self.logger.info("Params: {} ".format(params)) if is_success: products = data['products'] page = data['page'] count = len(products) self.logger.info("Response_content_count:{}".format(count)) context.update({'paginator': page, 'page_range': calculate_page_range_from_page_info(page)}) context['search_count'] = page['total_elements'] context['data'] = products elif (status_code == "access_token_expire") or (status_code == 'authentication_fail') or ( status_code == 'invalid_access_token'): self.logger.info("{}".format(data)) raise InvalidAccessToken(data) context['permissions'] = permissions self.logger.info('========== Finished searching products ==========') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): if not check_permissions_by_user(request.user, 'CAN_SEARCH_AGENT'): return render(request, 'web/permission-denied.html') # Get params agent_id = request.POST.get('agent_id') unique_reference = request.POST.get('unique_reference') email = request.POST.get('email') primary_mobile_number = request.POST.get('primary_mobile_number') kyc_status = request.POST.get('kyc_status') from_created_timestamp = request.POST.get('from_created_timestamp') to_created_timestamp = request.POST.get('to_created_timestamp') opening_page_index = request.POST.get('current_page_index') edc_serial_number = request.POST.get('edc_serial_number') mobile_device_unique_reference = request.POST.get( 'mobile_device_unique_reference') # Build Body context = {} body = {} body['paging'] = True body['page_index'] = int(opening_page_index) if agent_id: body['id'] = int(agent_id) if unique_reference: body['unique_reference'] = unique_reference if email: body['email'] = email if primary_mobile_number: body['primary_mobile_number'] = primary_mobile_number if kyc_status and isinstance(kyc_status, str): if kyc_status.lower() == "true": new_kyc_status = True else: new_kyc_status = False body['kyc_status'] = new_kyc_status context['kyc_status'] = kyc_status if edc_serial_number: body['edc_serial_number'] = edc_serial_number if mobile_device_unique_reference: body[ 'mobile_device_unique_reference'] = mobile_device_unique_reference context.update(body) new_from_created_timestamp = '' if from_created_timestamp is not '': new_from_created_timestamp = datetime.strptime( from_created_timestamp, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['from_created_timestamp'] = new_from_created_timestamp context['from_created_timestamp'] = from_created_timestamp new_to_created_timestamp = '' if to_created_timestamp is not '': new_to_created_timestamp = datetime.strptime( to_created_timestamp, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace( hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['to_created_timestamp'] = new_to_created_timestamp context['to_created_timestamp'] = to_created_timestamp # Get Data data, success, status_message = self._get_agents(params=body) if not success: if status_message == 'timeout': context.update({ 'msgs': { 'get_list_timeout': 'Search timeout, please try again' } }) context['search_count'] = 0 else: agents_list = data.get("agents", []) page = data.get("page", {}) context.update({ 'search_count': page.get('total_elements', 0), 'data': agents_list, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page) }) context['has_permission_search'] = check_permissions_by_user( self.request.user, "CAN_SEARCH_AGENT") self.update_session(request, None, agent_id, unique_reference, email, primary_mobile_number, kyc_status, edc_serial_number, mobile_device_unique_reference, new_from_created_timestamp, new_to_created_timestamp, False, False) return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): self.logger.info('========== Start search partner report ==========') context = super(PartnerReport, self).get_context_data(**kwargs) partner_file_id = context.get('partner_file_id') if partner_file_id is not None: partner_file_id = int(partner_file_id) opening_page_index = request.POST.get('current_page_index') on_off_us_id = int(request.POST.get('on_off_us_id')) service_group_id = request.POST.get('service_group_id') service_name = request.POST.get('service_id') agent_id = request.POST.get('partner_id') currency_id = request.POST.get('currency_id') reconcile_status_id = int(request.POST.get('reconcile_status_id')) reconcile_payment_type_id = request.POST.get('reconcile_payment_type_id') from_created_timestamp = request.POST.get('from_created_timestamp') to_created_timestamp = request.POST.get('to_created_timestamp') self.logger.info('On us/Off us: {}'.format(on_off_us_id)) self.logger.info('Service group: {}'.format(service_group_id)) self.logger.info('Service name: {}'.format(service_name)) self.logger.info('Agent id: {}'.format(agent_id)) self.logger.info('Currency: {}'.format(currency_id)) self.logger.info('Reconcile status: {}'.format(reconcile_status_id)) self.logger.info('Payment type: {}'.format(reconcile_payment_type_id)) self.logger.info('Start date: {}'.format(from_created_timestamp)) self.logger.info('End date: {}'.format(to_created_timestamp)) params = {} params['opening_page_index'] = opening_page_index if partner_file_id is not None: params['partner_file_id'] = partner_file_id if on_off_us_id >= 0: params['is_on_us'] = (on_off_us_id == 1) if service_name is None: params['service_name'] = '' elif service_name != '': params['service_name'] = service_name if currency_id != '': params['currency'] = currency_id if agent_id is not None and agent_id != '': params['agent_id'] = int(agent_id) if reconcile_status_id >=0: params['status_id'] = reconcile_status_id if reconcile_payment_type_id != '' and reconcile_payment_type_id != "-1": params['payment_type'] = reconcile_payment_type_id if from_created_timestamp is not '': new_from_created_timestamp = datetime.strptime(from_created_timestamp, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') params['from_last_updated_timestamp'] = new_from_created_timestamp if to_created_timestamp is not '': new_to_created_timestamp = datetime.strptime(to_created_timestamp, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace(hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') params['to_last_updated_timestamp'] = new_to_created_timestamp currencies, success = self._get_currency_choices() if success is True: context.update({'currencies': currencies}) services_list, service_groups, service_group_id, success = self._get_service_group_and_services_list(service_group_id) if success is True: context.update({'service_list': services_list, 'service_groups': service_groups, 'service_group_id': service_group_id}) else: context.update({'partner_report_update_msg': 'Fail to get service group, please refresh the page or contact technical support'}) params['service_name'] = None try: data, page, status_code = self._search_partner_report(params) if status_code == 500: self.logger.error('Search fail, please try again or contact technical support') context.update( {'partner_report_update_msg': 'Search fail, please try again or contact technical support'}) else: context.update({'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'partner_report': data}) except requests.Timeout as e: logger.error("Search Partner Report Timeout", e) context.update({'partner_report_update_msg': 'Search timeout, please try again or contact technical support'}) context.update({'is_on_us': on_off_us_id, 'selected_service': service_name, 'agent_id': agent_id, 'currency_id': currency_id, 'reconcile_status_id': reconcile_status_id, 'reconcile_payment_type_id': reconcile_payment_type_id, 'from_created_timestamp': from_created_timestamp, 'to_created_timestamp': to_created_timestamp, }) if partner_file_id is not None: context.update({'partner_file_id': partner_file_id}) self.logger.info("========== Finish search partner report ==========") return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): self.logger.info('========== Start showing Agent List page ==========') context = { 'msgs': { 'update_msg': self.request.session.pop('agent_update_msg', None), 'del_msg': self.request.session.pop('agent_delete_msg', None) } } from_created_timestamp = datetime.now() to_created_timestamp = datetime.now() unique_reference = None email = None primary_mobile_number = None kyc_status = None agent_id = None edc_serial_number = None mobile_device_unique_reference = None # Build Body body = {} body['paging'] = True body['page_index'] = 1 redirect_from_delete = self.request.session.pop( 'agent_redirect_from_delete', None) redirect_from_wallet_view = self.request.session.pop( 'agent_redirect_from_wallet_view', None) if redirect_from_delete or redirect_from_wallet_view: agent_id = self.request.session.pop('agent_id', None) unique_reference = self.request.session.pop( 'agent_unique_reference', None) email = self.request.session.pop('agent_email', None) primary_mobile_number = self.request.session.pop( 'agent_primary_mobile_number', None) kyc_status = self.request.session.pop('agent_kyc_status', None) edc_serial_number = self.request.session.pop( 'edc_serial_number', None) mobile_device_unique_reference = self.request.session.pop( 'mobile_device_unique_reference', None) if request.session['agent_from'] != '': from_created_timestamp = datetime.strptime( request.session['agent_from'], "%Y-%m-%dT%H:%M:%SZ") new_from_created_timestamp = from_created_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") body['from_created_timestamp'] = new_from_created_timestamp new_from_created_timestamp = from_created_timestamp.strftime( "%Y-%m-%d") context['from_created_timestamp'] = new_from_created_timestamp else: context['from_created_timestamp'] = '' if request.session['agent_to'] != '': to_created_timestamp = datetime.strptime( request.session['agent_to'], "%Y-%m-%dT%H:%M:%SZ") new_to_created_timestamp = to_created_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") body['to_created_timestamp'] = new_to_created_timestamp new_to_created_timestamp = to_created_timestamp.strftime( "%Y-%m-%d") context['to_created_timestamp'] = new_to_created_timestamp else: context['to_created_timestamp'] = '' context.update({ 'msgs': { 'delete_failed_msg': self.request.session.pop('agent_message', None) } }) else: # Set first load default time for Context from_created_timestamp = from_created_timestamp.replace(hour=0, minute=0, second=1) to_created_timestamp = to_created_timestamp.replace(hour=23, minute=59, second=59) new_from_created_timestamp = from_created_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") new_to_created_timestamp = to_created_timestamp.strftime( "%Y-%m-%dT%H:%M:%SZ") body['from_created_timestamp'] = new_from_created_timestamp new_from_created_timestamp = from_created_timestamp.strftime( "%Y-%m-%d") context['from_created_timestamp'] = new_from_created_timestamp body['to_created_timestamp'] = new_to_created_timestamp new_to_created_timestamp = to_created_timestamp.strftime( "%Y-%m-%d") context['to_created_timestamp'] = new_to_created_timestamp if agent_id: body.update({'id': int(agent_id)}) context.update({'id': int(agent_id)}) if unique_reference: body.update({'unique_reference': unique_reference}) if email: body.update({'email': email}) if primary_mobile_number: body.update({'primary_mobile_number': primary_mobile_number}) if kyc_status: if kyc_status and isinstance(kyc_status, str): if kyc_status.lower() == "true": body.update({'kyc_status': True}) else: body.update({'kyc_status': False}) if edc_serial_number: body.update({'edc_serial_number': edc_serial_number}) if mobile_device_unique_reference: body.update({ 'mobile_device_unique_reference': mobile_device_unique_reference }) context.update({ 'unique_reference': unique_reference, 'email': email, 'primary_mobile_number': primary_mobile_number, 'edc_serial_number': edc_serial_number, 'mobile_device_unique_reference': mobile_device_unique_reference, 'kyc_status': body.get('kyc_status', None), 'has_permission_search': check_permissions_by_user(self.request.user, "CAN_SEARCH_AGENT") }) # Get Data data, success, status_message = self._get_agents(params=body) if not success: if status_message == 'timeout': context.update({ 'msgs': { 'get_list_timeout': 'Search timeout, please try again' } }) context['search_count'] = 0 else: agents_list = data.get("agents", []) page = data.get("page", {}) context.update({ 'search_count': page.get('total_elements', 0), 'data': agents_list, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page) }) self.update_session( request, None, agent_id, unique_reference, email, primary_mobile_number, kyc_status, edc_serial_number, mobile_device_unique_reference, from_created_timestamp.strftime("%Y-%m-%dT%H:%M:%SZ"), to_created_timestamp.strftime("%Y-%m-%dT%H:%M:%SZ"), False, False) self.logger.info( '========== Finished showing Agent List page ==========') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): opening_page_index = request.POST.get('current_page_index') function = int(request.POST.get('function')) function_list = self._get_function_list() status = int(request.POST.get('status')) filename = request.POST.get('filename') file_id = request.POST.get('file_id') uploaded_by = request.POST.get('uploaded_by') uploaded_from = request.POST.get('uploaded_from') uploaded_to = request.POST.get('uploaded_to') postingFileId = request.POST.get('postingFileId') body = {} body['page_index'] = int(opening_page_index) if filename != '': body['file_name'] = filename if file_id: body['id'] = int(file_id) if uploaded_by: body['uploaded_username'] = uploaded_by # if uploaded_from: if function != 0: body['function_id'] = function if status != 0: body['status_id'] = status if postingFileId: if not check_permissions_by_user(self.request.user, "CAN_POST_UPLOAD_RESULT"): return redirect("web:permission_denied") postBodyData = {} postBodyData['file_id'] = postingFileId is_success, data = self._post_file(postBodyData) if uploaded_from: new_from_created_timestamp = datetime.strptime( uploaded_from, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['from_created_timestamp'] = new_from_created_timestamp if uploaded_to: new_to_created_timestamp = datetime.strptime( uploaded_to, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace( hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['to_created_timestamp'] = new_to_created_timestamp self.logger.info('========== Start searching file ==========') is_success, data = self._search_file(body) self.logger.info('========== Finished searching file ==========') if is_success: page = data['page'] context = { 'data': data['file_uploads'], 'filename': filename, 'file_id': file_id, 'function_id': function, 'function_list': function_list, 'status_id': status, 'uploaded_by': uploaded_by, 'uploaded_from': uploaded_from, 'uploaded_to': uploaded_to, 'paginator': page, 'search_count': page['total_elements'], 'page_range': calculate_page_range_from_page_info(page), 'status_list_map': status_list_map } return render(request, self.template_name, context)
def get(self, request, *args, **kwargs): context = super(ListView, self).get_context_data(**kwargs) # get undeleted services body_res = {'is_deleted': False, 'paging': False} service_list = get_service_list(self, body_res) is_deleted_status_list = [{ "value": "0", "name": "No" }, { "value": "1", "name": "Yes" }, { "value": "", "name": "All" }] http_method_list = [{ "value": "", "name": "All" }, { "value": "GET", "name": "GET" }, { "value": "POST", "name": "POST" }, { "value": "PUT", "name": "PUT" }, { "value": "DELETE", "name": "DELETE" }] context.update({ 'is_deleted_status_list': is_deleted_status_list, 'http_method_list': http_method_list, 'service_list': service_list }) opening_page_index = request.GET.get('current_page_index', 1) api_id = request.GET.get('api_id', "") api_name = request.GET.get('api_name', "") service_id = request.GET.get('service_id', "") is_deleted = request.GET.get('is_deleted', "0") http_method = request.GET.get('http_method', "") params = {} params['paging'] = True params['page_index'] = int(opening_page_index) if api_id: params['id'] = api_id if api_name: params['name'] = api_name if service_id: params['service_id'] = int(service_id) if is_deleted: params['is_deleted'] = True if is_deleted == '1' else False if http_method: params['http_method'] = http_method channel_api_list = get_api_list(self, params) page = channel_api_list.get('page', {}) context.update({ 'channel_api_list': channel_api_list.get('apis', []), 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'total_result': page.get('total_elements', 0), "api_id": api_id, "api_name": api_name, "selected_deleted_status": is_deleted, "selected_http_method": http_method, "service_id": int(service_id) if service_id else "" }) return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): context = super(OTPList, self).get_context_data(**kwargs) self.logger.info('========== Start searching otp list ==========') user_id = request.POST.get('user_id', '') delivery_channel = request.POST.get('delivery_channel', '') user_ref_code = request.POST.get('user_ref_code', '') otp_id = request.POST.get('otp_id', '') email = request.POST.get('email', '') is_deleted = request.POST.get('is_deleted', '') mobile_number = request.POST.get('mobile_number', '') otp_reference_id = request.POST.get('otp_reference_id', '') is_success_verified = request.POST.get('is_success_verified', '') opening_page_index = request.POST.get('current_page_index') user_type = request.POST.get('user_type', '') from_created_timestamp = request.POST.get('from_created_timestamp') to_created_timestamp = request.POST.get('to_created_timestamp') from_time = request.POST.get('from_time') to_time = request.POST.get('to_time') body = {} if user_id: body['user_id'] = user_id if delivery_channel: if delivery_channel != 'All': body['delivery_channel'] = delivery_channel else: body['delivery_channel'] = None if user_ref_code: body['user_reference_code'] = user_ref_code if otp_id: body['id'] = otp_id if email: body['email'] = email if mobile_number: body['mobile_number'] = mobile_number if otp_reference_id: body['otp_reference_id'] = otp_reference_id if is_deleted: body['is_deleted'] = True if is_deleted == '1' else False if is_success_verified and is_success_verified != 'All': body['is_success_verified'] = True if is_success_verified == 'Yes' else False if user_type and user_type != 'All': body['user_type'] = user_type if from_created_timestamp: body['from'] = convert_string_to_date_time(from_created_timestamp, from_time) if to_created_timestamp: body['to'] = convert_string_to_date_time(to_created_timestamp, to_time) body['paging'] = True body['page_index'] = int(opening_page_index) otp_list, is_success = self.get_otp_list(body) page = otp_list.get("page", {}) context.update({ 'otp_id': otp_id, 'is_deleted': is_deleted, 'user_id': user_id, 'user_ref_code': user_ref_code, 'delivery_channel': delivery_channel, 'email': email, 'mobile_number': mobile_number, 'otp_reference_id': otp_reference_id, 'is_success_verified': is_success_verified, 'user_type': user_type, 'from_date': from_created_timestamp, 'to_date': to_created_timestamp, 'from_time': from_time, 'to_time': to_time, 'search_count': page.get('total_elements', 0), 'otp_list': otp_list['otps'], 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), }) self.logger.info('========== Finish searching otp list ==========') return render(request, self.template_name, context)
def post(self, request, *args, **kwargs): count = 0 order_id = request.POST.get('order_id') opening_page_index = request.POST.get('current_page_index') service_id = request.POST.get('service_name') payer_user_id = request.POST.get('payer_user_id') payer_user_type_id = request.POST.get('payer_user_type_id') payee_user_id = request.POST.get('payee_user_id') payee_user_type_id = request.POST.get('payee_user_type_id') ref_order_id = request.POST.get('ref_order_id') from_created_timestamp = request.POST.get('from_created_timestamp') to_created_timestamp = request.POST.get('to_created_timestamp') service_list = self.get_services_list() service_group_list = self.get_service_group_list() status_id = request.POST.get('status_id') requested_by_id = request.POST.get('requested_by_id') approved_by_id = request.POST.get('approved_by_id') payer_sof_type_id = request.POST.get('payer_sof_type_id') payee_sof_type_id = request.POST.get('payee_sof_type_id') reference_service_group_id = request.POST.get( 'reference_service_group_id') reference_service_id = request.POST.get('reference_service_id') batch_code = request.POST.get('batch_code') currency_code = request.POST.get('currency_code') currency_list = self._get_preload_currencies_dropdown() body = {} body['page_index'] = int(opening_page_index) if order_id: body['order_id'] = order_id if service_id: body['product_service_id'] = service_id service_id = int(service_id) if payer_user_id: body['payer_user_id'] = payer_user_id if payer_user_type_id.isdigit() and payer_user_type_id != '0': body['payer_user_type_id'] = int(payer_user_type_id) if payee_user_id: body['payee_user_id'] = payee_user_id if payee_user_type_id.isdigit() and payee_user_type_id != '0': body['payee_user_type_id'] = int(payee_user_type_id) if payer_sof_type_id.isdigit() and payer_sof_type_id != '0': body['payer_user_sof_type_id'] = int(payer_sof_type_id) if payee_sof_type_id.isdigit() and payee_sof_type_id != '0': body['payee_user_sof_type_id'] = int(payee_sof_type_id) if reference_service_group_id.isdigit( ) and reference_service_group_id != '0': reference_service_group_id = int(reference_service_group_id) body['reference_service_group_id'] = reference_service_group_id if reference_service_id.isdigit() and reference_service_id != '0': reference_service_id = int(reference_service_id) body['reference_service_id'] = reference_service_id if ref_order_id: body['reference_order_id'] = ref_order_id if status_id: body['status'] = status_id if requested_by_id: body['created_user_id'] = requested_by_id if approved_by_id: body['approved_user_id'] = approved_by_id if batch_code: body['batch_code'] = batch_code if currency_code: body['currency'] = currency_code if from_created_timestamp is not '' and to_created_timestamp is not None: new_from_created_timestamp = datetime.strptime( from_created_timestamp, "%Y-%m-%d") new_from_created_timestamp = new_from_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['created_timestamp_from'] = new_from_created_timestamp if to_created_timestamp is not '' and to_created_timestamp is not None: new_to_created_timestamp = datetime.strptime( to_created_timestamp, "%Y-%m-%d") new_to_created_timestamp = new_to_created_timestamp.replace( hour=23, minute=59, second=59) new_to_created_timestamp = new_to_created_timestamp.strftime( '%Y-%m-%dT%H:%M:%SZ') body['created_timestamp_to'] = new_to_created_timestamp self.logger.info( '========== Start searching balance adjustment ==========') self.logger.info("Params: {} ".format(body)) is_success, status_code, status_message, data = RestFulClient.post( url=BALANCE_ADJUSTMENT_PATH, headers=self._get_headers(), loggers=self.logger, params=body) if is_success: balance_adjustment_reference = data['balance_adjustment_reference'] page = data['page'] count = len(balance_adjustment_reference) self.logger.info("Response_content_count:{}".format(count)) self.logger.info("Page:{}".format(page)) context = { 'order_list': balance_adjustment_reference, 'order_id': order_id, 'service_id': service_id, 'data': service_list, 'service_group_list': service_group_list, 'payer_user_id': payer_user_id, 'payer_user_type_id': payer_user_type_id, 'payee_user_id': payee_user_id, 'payee_user_type_id': payee_user_type_id, 'search_count': count, 'requested_by_id': requested_by_id, 'approved_by_id': approved_by_id, 'payer_sof_type_id': payer_sof_type_id, 'payee_sof_type_id': payee_sof_type_id, 'reference_service_group_id': reference_service_group_id, 'reference_service_id': reference_service_id, 'status_list': self.status_list, 'date_from': from_created_timestamp, 'date_to': to_created_timestamp, 'ref_order_id': ref_order_id, 'batch_code': batch_code, 'paginator': page, 'page_range': calculate_page_range_from_page_info(page), 'search_count': page['total_elements'], 'currency_code': currency_code, 'currencies': currency_list } if status_id: context['status_id'] = int(status_id) self.logger.info( '========== Finished searching Balance Adjustment ==========') return render(request, self.template_name, context) elif status_code in [ "access_token_expire", 'authentication_fail', 'invalid_access_token' ]: self.logger.info("{}".format(data)) raise InvalidAccessToken(data) elif status_message == 'timeout': messages.add_message( request, messages.ERROR, 'Request timed-out, please try again or contact system administrator' ) return redirect('balance_adjustment:balance_adjustment_list')