-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix migration 0043_... * Use a xhtml2pdf version that is compatible with django 1.8 and 1.11 * Add git to dockerfile in order to install xhtml2pdf * Pin a released version of xhtml2pdf * Bump version 0.4.2
- Loading branch information
Showing
8 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,3 +309,4 @@ class Migration(migrations.Migration): | |
reverse_sql="" | ||
) | ||
] | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
|
||
from django.conf import settings | ||
|
||
|
||
class UnsupportedMediaPathException(Exception): | ||
pass | ||
|
||
|
||
def fetch_resources(uri, rel): | ||
""" | ||
Callback to allow xhtml2pdf/reportlab to retrieve Images,Stylesheets, etc. | ||
`uri` is the href attribute from the html link element. | ||
`rel` gives a relative path, but it's not used here. | ||
""" | ||
if settings.MEDIA_URL and uri.startswith(settings.MEDIA_URL): | ||
path = os.path.join(settings.MEDIA_ROOT, | ||
uri.replace(settings.MEDIA_URL, "")) | ||
elif settings.STATIC_URL and uri.startswith(settings.STATIC_URL): | ||
path = os.path.join(settings.STATIC_ROOT, | ||
uri.replace(settings.STATIC_URL, "")) | ||
if not os.path.exists(path): | ||
for d in settings.STATICFILES_DIRS: | ||
path = os.path.join(d, uri.replace(settings.STATIC_URL, "")) | ||
if os.path.exists(path): | ||
break | ||
elif uri.startswith("http://") or uri.startswith("https://"): | ||
path = uri | ||
else: | ||
raise UnsupportedMediaPathException('media urls must start with %s or %s' % ( | ||
settings.MEDIA_URL, settings.STATIC_URL)) | ||
|
||
return path |