[[\ from spyceConfig import db books = db.books.select() users = db.users.select_by(admin=False) ]] [[! def new_user(self, api): api.redirect.external('user-new.spy') api.response.end() ]] [[ current_user = db.users.selectone_by(name=request.login_id()) ]] Welcome, [[= current_user.name ]]


[[\ # sqlite3 has a bug that prevents using the simpler join # of (books, (users, loans)) book_loans = db.join(db.join(db.books, db.loans, isouter=True), db.users, isouter=True) ]] [[ for book_loan in book_loans.select():{ ]] [[ if book_loan.user_name:{ # loaned out ]] [[ if current_user.admin or current_user.classname == book_loan.classname:{ ]] [[ } ]] [[ }else:{ ]] [[ } ]] [[ } ]]
Title Published Author(s) On loan to Borrower's email Loaned
[[= book_loan.title ]] [[= book_loan.published_year ]] [[= book_loan.authors ]][[= book_loan.user_name ]][[= book_loan.email ]][[= book_loan.loan_date ]]

[[ if current_user.admin:{ ]]
[[ } ]]