Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save souen/701809 to your computer and use it in GitHub Desktop.
Save souen/701809 to your computer and use it in GitHub Desktop.
def get_absolute_url(self):
# We need to build the URL to the paperPage inside the digital paper
# of the linked publication.
# It's built with the linked publication's absolute_url + an anchor pointing
# to the right book and the right page, 0-indexed.
# ex: http://journal.liberation.fr/publication/liberation/460/#0_17
# The anchor is #0_17:
# - 0 -> first book of the publication
# - 17 -> paperPage.page_number == 18
if self.book.code == BOOK_CODE.QUOTIDIEN:
book_index0 = 0
else:
book_index0 = 1
page_index0 = self.page_number - 1
return '%s#%d_%d' % (self.publication.get_absolute_url(), book_index0, page_index0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment