Exemplo n.º 1
0
 def get_available_loans(self):
     """
     Get the resource types currently available to be loaned out for this edition.  Does NOT
     take into account the user's status (e.g. number of books out, in-library status, etc).
     This is like checking if this book is on the shelf.
     
     Returns [{'resource_id': uuid, 'resource_type': type, 'size': bytes}]
     
     size may be None"""
     
     return self._get_available_loans(borrow.get_edition_loans(self))
Exemplo n.º 2
0
    def get_available_loans(self):
        """
        Get the resource types currently available to be loaned out for this edition.  Does NOT
        take into account the user's status (e.g. number of books out, in-library status, etc).
        This is like checking if this book is on the shelf.
        
        Returns [{'resource_id': uuid, 'resource_type': type, 'size': bytes}]
        
        size may be None"""

        return self._get_available_loans(borrow.get_edition_loans(self))
Exemplo n.º 3
0
 def get_available_loans(self):
     """Returns [{'resource_id': uuid, 'resource_type': type, 'size': bytes}]
     
     size may be None"""
     
     default_type = 'bookreader'
     
     loans = []
     
     resource_pattern = r'acs:(\w+):(.*)'
     for resource_urn in self.get_lending_resources():
         print 'RESOURCE %s' % resource_urn
         if resource_urn.startswith('acs:'):
             (type, resource_id) = re.match(resource_pattern, resource_urn).groups()
             loans.append( { 'resource_id': resource_id, 'resource_type': type, 'size': None } )
         elif resource_urn.startswith('bookreader'):
             loans.append( { 'resource_id': resource_urn, 'resource_type': 'bookreader', 'size': None } )
         
     
     # Put default type at start of list, then sort by type name
     def loan_key(loan):
         if loan['resource_type'] == default_type:
             return '1-%s' % loan['resource_type']
         else:
             return '2-%s' % loan['resource_type']        
     loans = sorted(loans, key=loan_key)
     
     # Check if we have a possible loan - may not yet be fulfilled in ACS4
     if borrow.get_edition_loans(self):
         # There is a current loan or offer
         return []
         
     # Check if available - book status server
     # We shouldn't be out of sync but we fail safe
     for loan in loans:
         if borrow.is_loaned_out(loan['resource_id']):
             # Only a single loan of an item is allowed
             # XXX log out of sync state
             return []
     
     # XXX get file size
         
     return loans
Exemplo n.º 4
0
 def get_current_loans(self):
     return borrow.get_edition_loans(self)
Exemplo n.º 5
0
 def get_current_and_available_loans(self):
     current_loans = borrow.get_edition_loans(self)
     current_and_available_loans = (
         current_loans, self._get_available_loans(current_loans))
     return current_and_available_loans
Exemplo n.º 6
0
 def get_current_loans(self):
     return borrow.get_edition_loans(self)
Exemplo n.º 7
0
 def get_current_and_available_loans(self):
     current_loans = borrow.get_edition_loans(self)
     current_and_available_loans = (current_loans, self._get_available_loans(current_loans))
     return current_and_available_loans
Exemplo n.º 8
0
 def update_loan_status(self):
     """Update the loan status"""
     # $$$ search in the store and update
     loans = borrow.get_edition_loans(self)
     for loan in loans:
         borrow.update_loan_status(loan['resource_id'])
Exemplo n.º 9
0
 def update_loan_status(self):
     """Update the loan status"""
     # $$$ search in the store and update
     loans = borrow.get_edition_loans(self)
     for loan in loans:
         borrow.update_loan_status(loan['resource_id'])