def getprofile(request): response = {'data': None, 'error': None, 'statusCode': None} try: config = getConfig() log = config['log'] configureLogging(log) cookieVal = '' try: cookieVal = validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "GET": all_profiles = getProfileData() response['data'] = 'Please enter Profile ID' response['error'] = 'No input Data' response['statusCode'] = 1 else: response['error'] = 'Sorry unable to get the response' response['statusCode'] = 1 except Exception as e: logging.error(str(e)) response['data'] = 'Authentication error' response['error'] = str(e) response['statusCode'] = 1 return JsonResponse(response)
def investmentProfileQuestionsView(request): response = { 'data':None, 'error':None, 'statusCode': 1 } try: config=getConfig() log=config['log'] configureLogging(log) cookieVal= '' try: cookieVal=validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "GET": #print(request.POST) profileQuestions=getProfileQuestionsService('I') #print(json.loads(request.body.decode('utf-8'))) response['statusCode'] = 0 response['data'] = profileQuestions except Exception as e: logging.error(str(e)) response['data'] = 'Error in retrieving Investment Profile questions' response['error'] = str(e) return JsonResponse(response)
def savePasswordPage(request): try: config = getConfig() log = config['log'] configureLogging(log) cookieVal= '' try: cookieVal=validateCookieService(request) except Exception as e: raise if request.method == 'GET': customerDetailsObj=getCustomerDetailsService(cookieVal) menuItemList=getMenuItemsByCustomerStatuService(customerDetailsObj.custstatus) currentPath=getCurrentPath(request.path) menuItemObjList = [child for menuItemObj in menuItemList for child in menuItemObj['child'] if child['menuItemLink'] == currentPath ] if len(menuItemObjList) == 1: return render(request,"home.html",{"template_name":"password.html","menuItemList":menuItemList}) else: raise Exception("Access Denied") except Exception as e: logging.error(str(e)) if str(e) == "Authentication failure": return redirect('/ui/login') elif str(e) == "Access Denied": return redirect('../home/default') else: errorMessage = "Internal Server Error" redirectLink = False return render(request,"error.html",{'redirectLink':redirectLink,'errorMessage':errorMessage})
def savePassword(request): response = { 'data': None, 'error': None, 'statusCode': 1 } try: config = getConfig() log = config['log'] configureLogging(log) cookieVal= '' try: cookieVal=validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "PUT": #print(json.loads(request.body.decode('utf-8'))) saveClientPasswordService(json.loads(request.body.decode('utf-8')),cookieVal) # print(json.loads(request.body.decode('utf-8'))) response['statusCode'] = 0 response['data'] = 'Client password saved successfully' except Exception as e: logging.error(str(e)) response['data'] = 'Error in saving client password' response['error'] = str(e) return JsonResponse(response)
def subscriptionCompleted(request): response = {'data': None, 'error': None, 'statusCode': 1} try: config = getConfig() log = config['log'] configureLogging(log) cookieVal = '' try: cookieVal = validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "POST": subscriptionList = saveSubscriptionService( json.loads(request.body.decode('utf-8')), cookieVal) response['statusCode'] = 0 response['data'] = subscriptionList except Exception as e: logging.error(str(e)) response['data'] = 'Error in retrieving subscription data' response['error'] = str(e) return JsonResponse(response)
def getprofilebyid(request, id): response = {'data': None, 'error': None, 'statusCode': None} try: config = getConfig() log = config['log'] configureLogging(log) cookieVal = '' try: cookieVal = validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "GET": try: id = int(id) except: raise Exception("Profile ID must be a Number(Integer)") if id <= 0: raise Exception( "Profile ID must be a Positive number and must be Existed") else: if personalProfileDataByIdService(id) == 0: raise Exception("Personal Profile not Existed") else: epid = personalProfileDataByIdService(id) response['data'] = epid response['statusCode'] = 0 elif request.method == "PUT": try: id = int(id) except: raise Exception("Profile ID must be a Number(Integer)") if id <= 0: raise Exception( "Profile ID must be a Positive number and must be Existed") else: personalProfileEditDataByIdService( id, json.loads(request.body.decode('utf-8'))) response['data'] = "data has been successfully saved" response['statusCode'] = 0 else: response['error'] = 'Sorry unable to get the response' response['statusCode'] = 1 except Exception as e: logging.error(str(e)) response['data'] = 'Error in getting Personal Profile data' response['error'] = str(e) response['statusCode'] = 1 return JsonResponse(response)
def dashboardPage(request): try: config = getConfig() log = config['log'] configureLogging(log) cookieVal= '' try: cookieVal=validateCookieService(request) except Exception as e: raise if request.method == 'GET': customerDetailsObj=getCustomerDetailsService(cookieVal) custTaskObjs=getCustTasksByCustIdService(customerDetailsObj.id) profileLink = '' profileCompleted = False for custTask in custTaskObjs: if custTask.taskname =="Personal" and custTask.status == 'P': profileLink = 'personal-profile' profileCompleted = False break elif custTask.taskname == "Investment" and custTask.status == 'P': profileLink = 'investment-profile' profileCompleted = False break elif custTask.taskname == "Document" and custTask.status == 'P': profileLink = 'documents' profileCompleted = False break if profileLink == '': profileCompleted = True menuItemList=getMenuItemsByCustomerStatuService(customerDetailsObj.custstatus) currentPath=getCurrentPath(request.path) menuItemObjList = [child for menuItemObj in menuItemList for child in menuItemObj['child'] if child['menuItemLink'] == currentPath ] if len(menuItemObjList) == 1: return render(request,"home.html",{"template_name":"dashboardview1.html",'menuItemList':menuItemList,'profileLink':profileLink,'profileCompleted':profileCompleted}) else: raise Exception("Access Denied") except Exception as e: logging.error(str(e)) if str(e) == "Authentication failure": return redirect('/ui/login') elif str(e) == "Access Denied": return redirect('../home/default') else: errorMessage = "Internal Server Error" redirectLink = False return render(request,"error.html",{'redirectLink':redirectLink,'errorMessage':errorMessage})
def homePage(request): try: config = getConfig() log = config['log'] configureLogging(log) cookieVal= '' try: cookieVal=validateCookieService(request) except Exception as e: raise if request.method == 'GET': customerDetailsObj=getCustomerDetailsService(cookieVal) if customerDetailsObj.custstatus in "S,I" and not checkSubscriptionExpirationService(cookieVal): updateCustomerDetailsService({'custregmobile':cookieVal,'customerStatus':'E'}) return redirect('../home/default') if customerDetailsObj.custstatus == 'P': return redirect('../home/save-password') elif customerDetailsObj.custstatus == 'R': return redirect('../home/subscription') elif customerDetailsObj.custstatus == 'S': return redirect('../home/dashboard') elif customerDetailsObj.custstatus == 'I': return redirect('../home/invested') elif customerDetailsObj.custstatus == 'E': return redirect('../home/subscription') #return render(request,"home.html",{"template_name":"personalProfile.html"}) #return render(request,"home.html",{"template_name":"dashboardview1.html"}) except Exception as e: logging.error(str(e)) if str(e) == "Authentication failure": return redirect('/ui/login') else: errorMessage = "Internal Server Error" redirectLink = False return render(request,"error.html",{'redirectLink':redirectLink,'errorMessage':errorMessage})
def personalProfileView(request): response = {'data': None, 'error': None, 'statusCode': 1} try: config = getConfig() log = config['log'] configureLogging(log) cookieVal = '' try: cookieVal = validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "POST": #print(request.POST) #print(json.loads(request.body)) savePersonalProfileService( json.loads(request.body.decode('utf-8')), cookieVal) response['statusCode'] = 0 response['data'] = 'Personal Profile data saved successfully' elif request.method == "GET": custprofile = getcustPersonalProfileService(cookieVal) #print(custprofile) response['data'] = custprofile response['statusCode'] = 0 elif request.method == "PUT": updateCustPersonalProfileService( json.loads(request.body.decode('utf-8')), cookieVal) response[ 'data'] = 'Customer Personal Profile data updated successfully' response['statusCode'] = 0 except Exception as e: logging.error(str(e)) response['data'] = 'Error in saving Personal Profile data' response['error'] = str(e) return JsonResponse(response)
def InvestmentProfileView(request): response = { 'data':None, 'error':None, 'statusCode': 1 } try: config=getConfig() log=config['log'] configureLogging(log) cookieVal= '' try: cookieVal=validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "POST": saveInvestmentProfileService(json.loads(request.body.decode('utf-8')),cookieVal) response['statusCode'] = 0 response['data'] = 'Investment Profile data saved successfully' elif request.method == "GET": investmentProfielList = getInvestmentProfileService(cookieVal) response['statusCode'] = 0 response['data'] = investmentProfielList elif request.method == "PUT": updateInvestmentProfileService(json.loads(request.body.decode('utf-8')),cookieVal) response['statusCode'] = 0 response['data'] = 'Investment Profile data updated successfully' except Exception as e: logging.error(str(e)) response['data'] = 'Error in processing Investment Profile data' response['error'] = str(e) return JsonResponse(response)
def login(request): try: config = getConfig() log = config['log'] configureLogging(log) cookieVal = '' try: cookieVal=validateCookieService(request) raise Exception('Logged In') except Exception as e: if str(e) == "Logged In": raise if request.method == 'GET': return render(request,"index.html") except Exception as e: logging.error(str(e)) return redirect('home/default')
def reviewInvestment(request): response = {'data': None, 'error': None, 'statusCode': 1} try: config = getConfig() log = config['log'] configureLogging(log) cookieVal = '' try: cookieVal = validateCookieService(request) except Exception as e: if str(e) == "Authentication failure": response['statusCode'] = 5 raise if request.method == "POST": subscriptionList = reviewInvestmentService(cookieVal) response['statusCode'] = 0 response['data'] = subscriptionList except Exception as e: logging.error(str(e)) response['data'] = 'Error in retrieving subscription data' response['error'] = str(e) return JsonResponse(response)