Re-disable the HTML sanitize for now
[oweals/karmaworld.git] / karmaworld / apps / notes / views.py
index 2202a86ff6c0c0205c65c2b108e697a8a3a3372b..f1384ced4226d68894c3c0ddea37ec78dde06229 100644 (file)
@@ -20,15 +20,12 @@ 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
 
 def is_ppt(self):
-    if self.object.pdf_file:
-        print "is a ppt"
+    if self.object.file_type == 'ppt':
         return True
     return False
 
@@ -42,7 +39,7 @@ class NoteDetailView(DetailView):
         """ Generate custom context for the page rendering a Note
             + if pdf, set the `pdf` flag
         """
-        #kwargs['file_url'] = os.path.basename(_path)
+        # not current using these
         #kwargs['hostname'] = Site.objects.get_current()
 
         kwargs['pdf'] = is_pdf(self)
@@ -87,6 +84,8 @@ class NoteSaveView(FormView, SingleObjectMixin):
         self.object.year = form.cleaned_data['year']
         # use *arg expansion to pass tags a list of tags
         self.object.tags.add(*form.cleaned_data['tags'])
+        # User has submitted this form, so set the SHOW flag
+        self.object.is_hidden = False
         self.object.save()
         return super(NoteSaveView, self).form_valid(form)
 
@@ -125,14 +124,13 @@ class PDFView(DetailView):
     def get_context_data(self, **kwargs):
         """ Generate a path to the pdf file associated with this note
             by generating a path to the MEDIA_URL by hand """
-        # FIXME: There may be an undocumented,
-        #   but better way of handling media files in django
 
-        if is_ppt:
+        if is_ppt(self):
             kwargs['pdf_path'] = "{0}{1}".format(settings.MEDIA_URL,
                 os.path.basename(self.object.pdf_file.name))
-        elif is_pdf:
-            kwargs['pdf_path'] = "{0}{1}".format(settings.MEDIA_URL,
-                os.path.basename(self.object.note_file.name))
+        elif is_pdf(self):
+            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)