blank=True, null=True)
# Upload files to MEDIA_ROOT/notes/YEAR/MONTH/DAY, 2012/10/30/filename
+ # FIXME: because we are adding files by hand in tasks.py, upload_to is being ignored for media files
note_file = models.FileField(
storage=fs,
upload_to="notes/%Y/%m/%j/",
blank=True, null=True)
+ pdf_file = models.FileField(
+ storage=fs,
+ upload_to="notes/%Y/%m/%j/",
+ blank=True, null=True)
## post gdrive conversion data
embed_url = models.URLField(max_length=1024, blank=True, null=True)
# return a url ending in id
return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.id)
- def sanitize_html(self):
+ def sanitize_html(self, save=True):
""" if self contains html, find all <a> tags and add target=_blank
takes self
returns True/False on succ/fail and error or count
#apply the add attribute function
map(add_attribute_target, a_tags)
self.html = _html
- self.save()
+ if save:
+ self.save()
return True, len(a_tags)