adding model method for sanitize_html
authorSeth Woodworth <seth@sethish.com>
Thu, 18 Apr 2013 21:28:54 +0000 (17:28 -0400)
committerSeth Woodworth <seth@sethish.com>
Thu, 18 Apr 2013 21:28:54 +0000 (17:28 -0400)
karmaworld/apps/notes/models.py

index a9606211aac9a20afc4a12937cb15d155a466384..f34bb333deb06c67bdce09d312544c842f17f83e 100644 (file)
@@ -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 <a> 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)