Created
November 16, 2010 13:08
-
-
Save souen/701809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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