コード例 #1
0
def validatePhoneno(request):
    response = {
        'data': None,
        'error': None,
        'statusCode': 1
    }
    try:
        
        config = getConfig()
        log = config['log']
        configureLogging(log)
        if request.method == "POST":
            ip = get_client_ip(request)
            device = request.user_agent.device.family
            
            hasNoClientDetails = validateMobileandSaveService(json.loads(request.body.decode('utf-8')), ip, device)
            if hasNoClientDetails == True:
                #print(json.loads(request.body.decode('utf-8')))
                
                
                response['data'] = False
                response['error'] = 'null'
                response['statusCode'] = 0
            else:
                response['data'] = True
                response['error'] = 'null'
                response['statusCode'] = 0
                
    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in validating client phone number'
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #2
0
def validateClient(request):
    response = {
        'data': None,
        'error': None,
        'statusCode': 1
    }
    try:
       
        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "POST":
            if validateClientPasswordService(json.loads(request.body.decode('utf-8'))):
                # print(json.loads(request.body.decode('utf-8')))
                response['statusCode'] = 0
                response['data'] = 'Client credentials successfully validated'
            else:
                response['statusCode'] = 2
                response['data'] = 'Invalid client credentials'
                    
    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in validting client credentials '
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #3
0
ファイル: views.py プロジェクト: vinay-vinnu/webservices
def personalProfileView(request):
    response = {'data': None, 'error': None, 'statusCode': 1}
    try:
        if 'userName' in request.COOKIES:
            print(request.COOKIES['userName'])
        else:
            raise Exception("Authentication failure")

        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "POST":
            #print(request.POST)
            savePersonalProfileService(json.loads(
                request.body.decode('utf-8')))
            #print(json.loads(request.body.decode('utf-8')))
            response['statusCode'] = 0
            response['data'] = 'Personal Profile data saved successfully'
        elif request.method == "GET":
            print(type(request.GET.get("g")))

    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in saving Personal Profile data'
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #4
0
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})
コード例 #5
0
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)
コード例 #6
0
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)
コード例 #7
0
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)
コード例 #8
0
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)
コード例 #9
0
def verifyOTPByEmail(request):
    
    response = {
        'data': None,
        'error': None,
        'statusCode': 1
    }
    try:
        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "POST":
            otpStatus = verifyOTPByEmailService(json.loads(request.body.decode('utf-8')))
            
            if otpStatus == True:
                # print(json.loads(request.body.decode('utf-8')))
                response['statusCode'] = 0
                response['data'] = 'OTP successfully verified'
            else:
                response['statusCode'] = 3
                response['data'] = 'Invalid OTP'
                    
    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in validting client credentials '
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #10
0
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)
コード例 #11
0
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})
コード例 #12
0
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})
コード例 #13
0
def getCountryCodes(request):
    response = {'data': None, 'error': None, 'statusCode': 1}
    try:
        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "GET":
            countreyCodesList = getCountryCodesService()
            response['data'] = countreyCodesList
            response['statusCode'] = 0

    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in retreving country codes data'
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #14
0
def resendOTP(request):
    response = {
        'data': None,
        'error': None,
        'statusCode': 1
    }
    try:
        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "POST":
            resendOTPService(json.loads(request.body.decode('utf-8')))
            response['statusCode'] = 0
            response['data'] = "OTP Successfully sent again"
                    
    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in resending OTP'
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #15
0
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)
コード例 #16
0
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)
コード例 #17
0
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')    
コード例 #18
0
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)
コード例 #19
0
ファイル: views.py プロジェクト: vinay-vinnu/webservices
def savePassword(request):
    response = {'data': None, 'error': None, 'statusCode': 1}
    try:
        if 'userName' in request.COOKIES:
            print(request.COOKIES['userName'])
        else:
            raise Exception("Authentication failure")

        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "PUT":
            print(json.loads(request.body.decode('utf-8')))
            saveClientPasswordService(json.loads(request.body.decode('utf-8')))
            #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)
コード例 #20
0
ファイル: views.py プロジェクト: vinay-vinnu/webservices
def personalProfileQuestionsView(request):
    response = {'data': None, 'error': None, 'statusCode': 1}
    try:
        if 'userName' in request.COOKIES:
            print(request.COOKIES['userName'])
        else:
            raise Exception("Authentication failure")

        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "GET":
            #print(request.POST)
            profileQuestions = getPersonalProfileQuestionsService()
            #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 Personal Profile questions'
        response['error'] = str(e)
    return JsonResponse(response)
コード例 #21
0
ファイル: views.py プロジェクト: vinay-vinnu/webservices
def subscriptionsView(request):
    response = {'data': None, 'error': None, 'statusCode': 1}
    try:
        if 'userName' in request.COOKIES:
            print(request.COOKIES['userName'])
        else:
            raise Exception("Authentication failure")
        print(request.META['REMOTE_HOST'])
        print(request.META['REMOTE_ADDR'])
        print(request.META.get('HTTP_X_FORWARDED_FOR'))
        print(request.META['HTTP_USER_AGENT'])
        config = getConfig()
        log = config['log']
        configureLogging(log)

        if request.method == "GET":
            subscriptionList = getSubscriptionsService()
            response['statusCode'] = 0
            response['data'] = subscriptionList
    except Exception as e:
        logging.error(str(e))
        response['data'] = 'Error in saving Personal Profile data'
        response['error'] = str(e)
    return JsonResponse(response)