def post(self, args):
        if args[misc_webargs.ROLE.name] == roles.ADMIN.name:
            if auth.checkTokenRole(args[misc_webargs.REFERRER_USERNAME.name],
                                   roles.ADMIN.name,
                                   args[misc_webargs.REFERRER_TOKEN.name]):
                if auth.addUser(args[misc_webargs.USERNAME.name],
                                args[misc_webargs.PASSWORD.name],
                                args[misc_webargs.ROLE.name], "",
                                args[misc_webargs.TIMEZONE.name]):
                    return utils.generate_response(1, "SUCCESS")
        elif args[misc_webargs.ROLE.name] == roles.AGENT.name:
            if auth.checkTokenRole(args[misc_webargs.REFERRER_USERNAME.name],
                                   roles.ADMIN.name,
                                   args[misc_webargs.REFERRER_TOKEN.name]):
                if auth.addUser(args[misc_webargs.USERNAME.name],
                                args[misc_webargs.PASSWORD.name],
                                args[misc_webargs.ROLE.name], "",
                                args[misc_webargs.TIMEZONE.name]):
                    return utils.generate_response(1, "SUCCESS")
        elif args[misc_webargs.ROLE.name] == roles.CUSTOMER.name:
            if auth.checkRoles(args[misc_webargs.REFERRER_USERNAME.name],
                               roles.AGENT.name):
                if auth.addUser(args[misc_webargs.USERNAME.name],
                                args[misc_webargs.PASSWORD.name],
                                args[misc_webargs.ROLE.name],
                                args[misc_webargs.REFERRER_USERNAME.name],
                                args[misc_webargs.TIMEZONE.name]):
                    return utils.generate_response(1, "SUCCESS")

        return utils.generate_response(0, "FAILURE")
 def post(self, args):
     if auth.checkPassword(args[misc_webargs.USERNAME.name],
                           args[misc_webargs.PASSWORD.name]):
         token = utils.id_generator()
         if auth.addToken(args[misc_webargs.USERNAME.name], token):
             return utils.generate_response(1, {"TOKEN": token})
     return utils.generate_response(0, "FAILURE")
 def post(self, args):
     try:
         if auth.checkTokenRole(args[misc_webargs.REFERRER_USERNAME.name],
                                roles.ADMIN.name,
                                args[misc_webargs.REFERRER_TOKEN.name]):
             if auth.approveLoanRequest(args):
                 return utils.generate_response(1, "SUCCESS")
     except Exception as e:
         print(e)
     return utils.generate_response(0, "FAILURE")
 def post(self, args):
     try:
         if auth.checkToken(args[misc_webargs.USERNAME.name],
                            args[misc_webargs.TOKEN.name]):
             val = auth.viewLoansRequest(args[misc_webargs.USERNAME.name])
             return val
     except Exception as e:
         print(e)
         return utils.generate_response(0, "FAILURE")
     return utils.generate_response(0, "FAILURE")
    def post(self):
        try:
            initial_setup.generateUsersUniqueIndex()
            initial_setup.generateSuperadmin()
            initial_setup.generateLoan1()
            initial_setup.generateLoanInventoryIndex()
            initial_setup.insertInitialCounterValue()
        except Exception as e:
            print(e)
            return utils.generate_response(0, "FAILURE")

        return utils.generate_response(0, "SUCCESS")
 def post(self, args):
     try:
         if auth.checkTokenRole(args[misc_webargs.REFERRER_USERNAME.name],
                                roles.AGENT.name,
                                args[misc_webargs.REFERRER_TOKEN.name]):
             if auth.isCustomerAgentRelated(
                     args[misc_webargs.REFERRER_USERNAME.name],
                     args[misc_webargs.CUSTOMER_NAME.name]):
                 if auth.addLoan(args):
                     return utils.generate_response(1, "SUCCESS")
     except:
         return utils.generate_response(0, "FAILURE")
     return utils.generate_response(0, "FAILURE")
Beispiel #7
0
def getListOfUsers(username):
    expr = {constants.misc_webargs.USERNAME.name: {'$regex': generateExactMatchPattern(username), '$options': 'i'}}
    cursor = db.find_docs(constants.collectionName.users.name, expr)
    role = None
    for val in cursor:
        role = val[constants.misc_webargs.ROLE.name]
    if role == constants.roles.ADMIN.name:
        adminList = listOtherUsers(constants.roles.ADMIN.name, username)
        agentList = listOtherUsers(constants.roles.AGENT.name, username)
        customerList = listOtherUsers(constants.roles.CUSTOMER.name, username)
        return utils.generate_response(1, {constants.roles.ADMIN.name: adminList, constants.roles.AGENT.name: agentList,
                                           constants.roles.CUSTOMER.name: customerList})
    elif role == constants.roles.AGENT.name:
        adminList = listOtherUsers(constants.roles.ADMIN.name, username)
        agentList = listOtherUsers(constants.roles.AGENT.name, username)
        customerList = listCustomers(username)
        return utils.generate_response(1, {constants.roles.ADMIN.name: adminList, constants.roles.AGENT.name: agentList,
                                           constants.roles.CUSTOMER.name: customerList})
    else:
        return utils.generate_response(0, "FAILURE")
Beispiel #8
0
def viewLoansRequest(username):
    expr = {constants.misc_webargs.USERNAME.name: {'$regex': generateExactMatchPattern(username), '$options': 'i'}}
    cursor = db.find_docs(constants.collectionName.users.name, expr)
    role = None
    for val in cursor:
        role = val[constants.misc_webargs.ROLE.name]

    if role == constants.roles.ADMIN.name:
        expr = [{"$lookup": {"from": "loan_customer", "localField": "INSERTED_ID", "foreignField": "_id", "as": "R"}},
         {"$project":{"R._id":0, "INSERTED_ID":0,"_id":0,"R.TIMESTAMP":0,"LOAN_CUST_ID":0,"USERNAME":0}},{"$unwind": "$R"}]
    elif role == constants.roles.AGENT.name:
        expr = [{"$lookup": {"from": "loan_customer", "localField": "INSERTED_ID", "foreignField": "_id", "as": "R"}},
         {"$project":{"R._id":0, "INSERTED_ID":0,"_id":0,"R.TIMESTAMP":0,"LOAN_CUST_ID":0,"USERNAME":0}},{"$match":{"R.REFERRER_USERNAME":username}},{"$unwind": "$R"}]
    else:
        expr = [{"$lookup": {"from": "loan_customer", "localField": "INSERTED_ID", "foreignField": "_id", "as": "R"}},
         {"$project":{"R._id":0, "INSERTED_ID":0,"_id":0,"R.TIMESTAMP":0,"LOAN_CUST_ID":0,"USERNAME":0}},{"$match":{"R.CUSTOMER_NAME":username}},{"$unwind": "$R"}]

    listData = []


    req_coll = db.aggregate_db(constants.collectionName.loan_customer_counter.name, expr)
    for val in list(req_coll):
        listData.append(val)
    return utils.generate_response(1, listData)
 def post(self):
     try:
         val = auth.listLoans()
     except:
         return utils.generate_response(0, "FAILURE")
     return utils.generate_response(1, val)
 def post(self, args):
     if auth.checkToken(args[misc_webargs.REFERRER_USERNAME.name],
                        args[misc_webargs.TOKEN.name]):
         if auth.editUserInfo(args):
             return utils.generate_response(1, "SUCCESS")
     return utils.generate_response(0, "FAILURE")
 def post(self, args):
     if auth.checkToken(args[misc_webargs.USERNAME.name],
                        args[misc_webargs.TOKEN.name]):
         response = auth.getListOfUsers(args[misc_webargs.USERNAME.name])
         return response
     return utils.generate_response(0, "FAILURE")