Ejemplo n.º 1
0
    def _prepare_data(
        self,
        logged_in_user,
        sponsorships=None,
        page=1,
        username=None,
    ):
        if sponsorships:
            return (web.ctx.site.get(
                web.ctx.site.things({
                    'type': '/type/edition',
                    'isbn_%s' % len(s['isbn']): s['isbn']
                })[0]) for s in sponsorships)

        if self.key == 'loans':
            logged_in_user.update_loan_status()
            return borrow.get_loans(logged_in_user)
        elif self.key == 'waitlist':
            return {}
        elif self.key == 'lists':
            if username:
                return web.ctx.site.get('/people/%s' % username)
            return self.user
        elif self.key == 'notes':
            return PatronBooknotes(self.user).get_notes(page=page)
        elif self.key == 'observations':
            return PatronBooknotes(self.user).get_observations(page=page)
        elif self.key == 'imports':
            return {}

        return None
Ejemplo n.º 2
0
    def GET(self):
        try:
            if 'counts_db' in config.admin:
                stats = admin.get_stats()
            else:
                stats = None
        except Exception:
            logger.error("Error in getting stats", exc_info=True)
            stats = None
        blog_posts = get_blog_feeds()

        lending_list = config.get("home", {}).get("lending_list")
        returncart_list = config.get("home", {}).get("returncart_list")

        user = accounts.get_current_user()
        loans = borrow.get_loans(user) if user else None

        return render_template("home/index",
                               stats=stats,
                               blog_posts=blog_posts,
                               lending_list=lending_list,
                               returncart_list=returncart_list,
                               user=user,
                               loans=loans,
                               popular_books=[],
                               waitlisted_books=[])
Ejemplo n.º 3
0
    def GET(self):
        try:
            if 'counts_db' in config.admin:
                stats = admin.get_stats()
            else:
                stats = None
        except Exception:
            logger.error("Error in getting stats", exc_info=True)
            stats = None
        blog_posts = get_blog_feeds()

        lending_list = config.get("home", {}).get("lending_list")
        returncart_list = config.get("home", {}).get("returncart_list")

        user = accounts.get_current_user()
        loans = borrow.get_loans(user) if user else None

        popular_available, popular_waitlist = popular_carousel()
        return render_template(
            "home/index", stats=stats,
            blog_posts=blog_posts,
            lending_list=lending_list,
            returncart_list=returncart_list,
            user=user, loans=loans,
            popular_books=popular_available,
            waitlisted_books=popular_waitlist
        )
Ejemplo n.º 4
0
 def GET(self):
     user = accounts.get_current_user()
     user.update_loan_status()
     loans = borrow.get_loans(user)
     web.header('Content-Type', 'application/json')
     return delegate.RawText(json.dumps({
         "loans": loans
     }))
Ejemplo n.º 5
0
    def _prepare_data(
        self,
        logged_in_user,
        page=1,
        username=None,
    ):
        if self.key == 'loans':
            logged_in_user.update_loan_status()
            return borrow.get_loans(logged_in_user)
        elif self.key == 'waitlist':
            return {}
        elif self.key == 'lists':
            if username:
                return web.ctx.site.get('/people/%s' % username)
            return self.user
        elif self.key == 'notes':
            return PatronBooknotes(self.user).get_notes(page=page)
        elif self.key == 'observations':
            return PatronBooknotes(self.user).get_observations(page=page)
        elif self.key == 'imports':
            return {}

        return None
Ejemplo n.º 6
0
 def GET(self):
     user = accounts.get_current_user()
     user.update_loan_status()
     loans = borrow.get_loans(user)
     return render['account/borrow'](user, loans)
Ejemplo n.º 7
0
 def get_loans(self):
     return borrow.get_loans(self.user)
Ejemplo n.º 8
0
 def get_loan_count(self):
     return len(borrow.get_loans(self))