Commit 8829fdafb58b0f6a51748364c5756473ab8d7d48
1 parent
323ccfdc
Exists in
master
and in
2 other branches
Passing absolute url to pdf view to show in mobile browsers
Showing
2 changed files
with
3 additions
and
1 deletions
Show diff stats
pdf_file/templates/pdf_file/view.html
@@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
49 | </div> | 49 | </div> |
50 | </div> | 50 | </div> |
51 | <object width="100%" height="800px" type="application/pdf" data="{{pdf_file.file.url}}" id="pdf_content"> | 51 | <object width="100%" height="800px" type="application/pdf" data="{{pdf_file.file.url}}" id="pdf_content"> |
52 | - <iframe id="pdfviewer" src="http://docs.google.com/gview?embedded=true&url={{pdf_file.file.url}}" frameborder="0" width="100%" height="800px"></iframe> | 52 | + <iframe id="pdfviewer" src="https://docs.google.com/gview?embedded=true&url={{ absolute_url }}" frameborder="0" width="100%" height="800px"></iframe> |
53 | {# <p>{% trans "PDF could not be displayed" %}</p> #} | 53 | {# <p>{% trans "PDF could not be displayed" %}</p> #} |
54 | </object> | 54 | </object> |
55 | {% endblock content %} | 55 | {% endblock content %} |
56 | \ No newline at end of file | 56 | \ No newline at end of file |
pdf_file/views.py
@@ -53,7 +53,9 @@ class ViewPDFFile(LoginRequiredMixin, LogMixin, generic.TemplateView): | @@ -53,7 +53,9 @@ class ViewPDFFile(LoginRequiredMixin, LogMixin, generic.TemplateView): | ||
53 | context = super(ViewPDFFile, self).get_context_data(**kwargs) | 53 | context = super(ViewPDFFile, self).get_context_data(**kwargs) |
54 | slug = self.kwargs.get('slug', '') | 54 | slug = self.kwargs.get('slug', '') |
55 | pdf_file = PDFFile.objects.get(slug=slug) | 55 | pdf_file = PDFFile.objects.get(slug=slug) |
56 | + | ||
56 | context['pdf_file'] = pdf_file | 57 | context['pdf_file'] = pdf_file |
58 | + context['absolute_url'] = self.request.build_absolute_uri(pdf_file.file.url) | ||
57 | context['subject'] = pdf_file.topic.subject | 59 | context['subject'] = pdf_file.topic.subject |
58 | 60 | ||
59 | self.log_context['category_id'] = pdf_file.topic.subject.category.id | 61 | self.log_context['category_id'] = pdf_file.topic.subject.category.id |