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
""" 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)
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)
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:
+ elif is_pdf(self):
kwargs['pdf_path'] = "{0}{1}".format(settings.MEDIA_URL,
os.path.basename(self.object.note_file.name))