From: Seth Woodworth Date: Thu, 18 Apr 2013 21:28:54 +0000 (-0400) Subject: adding model method for sanitize_html X-Git-Tag: release-20150131~445 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b7985ba282597a68162d4760492f30be6a7490b9;p=oweals%2Fkarmaworld.git adding model method for sanitize_html --- diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index a960621..f34bb33 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -110,7 +110,7 @@ class Note(models.Model): # 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 tags and add target=_blank takes self returns True/False on succ/fail and error or count @@ -130,7 +130,8 @@ class Note(models.Model): #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)