Beispiel #1
0
def get_data_db():
    data = [{
        'name': bank.name,
        'buy': bank.buy,
        'sell': bank.sells
    } for bank in Bank.select()]
    return data
Beispiel #2
0
def failed_bank_detail(cert_num):
    """
    This route is for a single bank.
    We're going to do TWO things.
    a.) We're going to get the one bank.
    b.) We're going to get all banks EXCEPT this bank in the same state.
    """
    # a.) Get this bank.
    this_bank = Bank.select().where(Bank.cert_num == int(cert_num)).get()

    # b.) Get the other banks in this state.
    same_state_banks = Bank.select().where(Bank.state == this_bank.state).where(Bank.cert_num != int(cert_num))

    # Set up the context; include both this bank and other banks from this state.
    context = {"bank": this_bank, "same_state_banks": same_state_banks}

    # Render the template to detail.html and with that context.
    return render_template("detail.html", **context)
Beispiel #3
0
def failed_banks_list():
    """
    This route is for a list of ALL banks.
    """

    # The context for this pages is just "banks", a list of all banks.
    context = {"banks": Bank.select()}

    # Render the template to list.html and with the context from above.
    return render_template("list.html", **context)
Beispiel #4
0
    def run(self):
        central_bank = self.get_central_bank()

        print("Total registered banks: %d" % Bank.select().count())
        print()
        print("List of banks")

        index = 1

        print('no\tname\tmanager\tbalance\tcustomer')
        columns_count = 5
        print('-' * (8 * columns_count))

        # TODO: filter by central bank
        for bank in Bank.select():
            customers = Customer.filter(bank=bank)
            balance = bank.manager.wallet.get_balance()

            print('%d\t%s\t%s\t%.2f\t%d' %
                  (index, bank.bank_name, bank.manager.username, balance,
                   len(customers)))
            index += 1

        print()