As with the index() method, we first initialize the same variables as, ultimately, we'll be sending results to the same template for rendering:
def payments(request) :
loan = Loan()
amtPaid = 0.00
amtDue = 0.00
message = ''
borrower = None
borrowerKey = None
borrowerName = ''
overpayment = 0.00
We then initialize payments as a list with a single blank Payment instance:
payment = Payment()
payments = [payment.populate()]
Next, in a similar manner to the index() method, we get instances of domain service classes representing users and loans. With the user domain service, we retrieve a list of borrower keys and names:
config = Config()
userSvc = UserService(config, 'User')
loanSvc = LoanService(config, 'Loan')
borrowers = userSvc.fetchBorrowerKeysAndNames()
We then check to see if the HTTP request method was POST. If so, we check...