Detect and display PDF and PPT note files
authorJosh Williams <jwilliams@endpoint.com>
Thu, 26 Sep 2013 19:27:29 +0000 (15:27 -0400)
committerJosh Williams <jwilliams@endpoint.com>
Thu, 26 Sep 2013 19:27:29 +0000 (15:27 -0400)
karmaworld/apps/notes/views.py

index f19cdff42efc1625561a6b4b06978da4f4845652..f1384ced4226d68894c3c0ddea37ec78dde06229 100644 (file)
@@ -20,9 +20,7 @@ from karmaworld.apps.notes.forms import NoteForm
 
 
 def is_pdf(self):
-    _path = self.object.note_file.name
-    _, _extension = os.path.splitext(_path)
-    if _extension.lower() == '.pdf':
+    if self.object.file_type == 'pdf':
         return True
     return False
 
@@ -131,7 +129,8 @@ class PDFView(DetailView):
             kwargs['pdf_path'] = "{0}{1}".format(settings.MEDIA_URL,
                 os.path.basename(self.object.pdf_file.name))
         elif is_pdf(self):
-            kwargs['pdf_path'] = "{0}{1}".format(settings.MEDIA_URL,
-                os.path.basename(self.object.note_file.name))
+            kwargs['pdf_path'] = self.object.fp_file
+            #kwargs['pdf_path'] = "{0}{1}".format(settings.MEDIA_URL,
+            #    os.path.basename(self.object.note_file.name))
 
         return super(PDFView, self).get_context_data(**kwargs)