def _contributor_sublanes(self, _db): """Create contributor sublanes""" viable_contributors = list() roles_by_priority = list(Contributor.author_contributor_tiers())[1:] while roles_by_priority and not viable_contributors: author_roles = roles_by_priority.pop(0) viable_contributors = [ c.contributor for c in self.edition.contributions if c.role in author_roles ] for contributor in viable_contributors: contributor_name = None if contributor.display_name: # Prefer display names over sort names for easier URIs # at the /works/contributor/<NAME> route. contributor_name = contributor.display_name else: contributor_name = contributor.sort_name contributor_lane = ContributorLane(_db, self.library, contributor_name, parent=self) yield contributor_lane
def _contributor_sublanes(self, _db): """Create contributor sublanes""" viable_contributors = list() roles_by_priority = list(Contributor.author_contributor_tiers())[1:] while roles_by_priority and not viable_contributors: author_roles = roles_by_priority.pop(0) viable_contributors = [c.contributor for c in self.edition.contributions if c.role in author_roles] for contributor in viable_contributors: contributor_name = None if contributor.display_name: # Prefer display names over sort names for easier URIs # at the /works/contributor/<NAME> route. contributor_name = contributor.display_name else: contributor_name = contributor.sort_name contributor_lane = ContributorLane( self.get_library(_db), contributor_name, parent=self, languages=self.languages, audiences=self.audiences, ) yield contributor_lane
def _contributor_sublanes(self, _db): """Create contributor sublanes""" viable_contributors = list() roles_by_priority = list(Contributor.author_contributor_tiers())[1:] while roles_by_priority and not viable_contributors: author_roles = roles_by_priority.pop(0) viable_contributors = [c.contributor for c in self.edition.contributions if c.role in author_roles] library = self.get_library(_db) for contributor in viable_contributors: contributor_lane = ContributorLane( library, contributor, parent=self, languages=self.languages, audiences=self.audiences, ) yield contributor_lane
def _get_sublanes(self, _db, license_pool, novelist_api=None): sublanes = list() edition = license_pool.presentation_edition # Create contributor sublanes. viable_contributors = list() roles_by_priority = list(Contributor.author_contributor_tiers())[1:] while roles_by_priority and not viable_contributors: author_roles = roles_by_priority.pop(0) viable_contributors = [c.contributor for c in edition.contributions if c.role in author_roles] for contributor in viable_contributors: contributor_name = None if contributor.display_name: # Prefer display names over sort names for easier URIs # at the /works/contributor/<NAME> route. contributor_name = contributor.display_name else: contributor_name = contributor.sort_name contributor_lane = ContributorLane( _db, contributor_name, contributor_id=contributor.id, parent=self ) sublanes.append(contributor_lane) # Create a recommendations sublane. try: lane_name = "Recommendations for %s by %s" % ( license_pool.work.title, license_pool.work.author ) recommendation_lane = RecommendationLane( _db, license_pool, lane_name, novelist_api=novelist_api, parent=self ) if recommendation_lane.recommendations: sublanes.append(recommendation_lane) except ValueError, e: # NoveList isn't configured. pass