def related_books_available(cls, license_pool): """:return: bool asserting whether related books are available for a particular work """ contributions = license_pool.presentation_edition.contributions series = license_pool.presentation_edition.series return contributions or series or NoveListAPI.is_configured()
def related_books_available(cls, work, library): """:return: bool asserting whether related books might exist for a particular Work """ contributions = work.sort_author and work.sort_author != Edition.UNKNOWN_AUTHOR return (contributions or work.series or NoveListAPI.is_configured(library))
def related_books_available(cls, work, library): """:return: bool asserting whether related books might exist for a particular Work """ if isinstance(work, Work): edition = work.presentation_edition else: # This is a MaterializedWork*, so we're gonna grab the # edition where we can. edition = work.license_pool.presentation_edition contributions = edition.contributions series = edition.series return contributions or series or NoveListAPI.is_configured(library)
def related_books_available(cls, license_pool): """:return: bool asserting whether related books are available for a particular work """ series = license_pool.presentation_edition.series return NoveListAPI.is_configured() or series
def annotate_work_entry(self, work, active_license_pool, edition, identifier, feed, entry): Annotator.annotate_work_entry( work, active_license_pool, edition, identifier, feed, entry ) active_loan = self.active_loans_by_work.get(work) active_hold = self.active_holds_by_work.get(work) active_fulfillment = self.active_fulfillments_by_work.get(work) # First, add a permalink. feed.add_link_to_entry( entry, rel='alternate', type=OPDSFeed.ENTRY_TYPE, href=self.permalink_for( work, active_license_pool, identifier ) ) # Add a link for reporting problems. feed.add_link_to_entry( entry, rel='issues', href=self.url_for( 'report', identifier_type=identifier.type, identifier=identifier.identifier, library_short_name=self.library.short_name, _external=True ) ) # Now we need to generate a <link> tag for every delivery mechanism # that has well-defined media types. link_tags = self.acquisition_links( active_license_pool, active_loan, active_hold, active_fulfillment, feed, identifier ) for tag in link_tags: entry.append(tag) # Add a link for each author. self.add_author_links(work, feed, entry) # And a series, if there is one. if work.series: self.add_series_link(work, feed, entry) if NoveListAPI.is_configured(self.library): # If NoveList Select is configured, there might be # recommendations, too. feed.add_link_to_entry( entry, rel='recommendations', type=OPDSFeed.ACQUISITION_FEED_TYPE, title='Recommended Works', href=self.url_for( 'recommendations', identifier_type=identifier.type, identifier=identifier.identifier, library_short_name=self.library.short_name, _external=True ) ) # Add a link for related books if available. if self.related_books_available(work, self.library): feed.add_link_to_entry( entry, rel='related', type=OPDSFeed.ACQUISITION_FEED_TYPE, title='Recommended Works', href=self.url_for( 'related_books', identifier_type=identifier.type, identifier=identifier.identifier, library_short_name=self.library.short_name, _external=True ) ) # Add a link to get a patron's annotations for this book. feed.add_link_to_entry( entry, rel="http://www.w3.org/ns/oa#annotationService", type=AnnotationWriter.CONTENT_TYPE, href=self.url_for( 'annotations_for_work', identifier_type=identifier.type, identifier=identifier.identifier, library_short_name=self.library.short_name, _external=True ) )