fix(null-handling): for doctype, doctype, ignore null values
This commit is contained in:
parent
e2d3b86374
commit
0284b1a965
3 changed files with 12 additions and 11 deletions
|
|
@ -48,10 +48,10 @@ class TestComment(unittest.TestCase):
|
|||
add_comment('pleez vizits my site http://mysite.com', 'test@test.com', 'bad commentor',
|
||||
'Blog Post', test_blog.name, test_blog.route)
|
||||
|
||||
self.assertEqual(frappe.get_all('Comment', fields = ['*'], filters = dict(
|
||||
self.assertEqual(len(frappe.get_all('Comment', fields = ['*'], filters = dict(
|
||||
reference_doctype = test_blog.doctype,
|
||||
reference_name = test_blog.name
|
||||
))[0].published, 0)
|
||||
))), 0)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ class BaseDocument(object):
|
|||
self.created_by = self.modified_by = frappe.session.user
|
||||
|
||||
# if doctype is "DocType", don't insert null values as we don't know who is valid yet
|
||||
d = self.get_valid_dict(convert_dates_to_str=True, ignore_nulls=self.doctype in ('DocType', 'DocField', 'DocPerm'))
|
||||
d = self.get_valid_dict(convert_dates_to_str=True, ignore_nulls = self.doctype in ('DocType', 'DocField', 'DocPerm'))
|
||||
|
||||
columns = list(d)
|
||||
try:
|
||||
|
|
@ -345,7 +345,7 @@ class BaseDocument(object):
|
|||
self.db_insert()
|
||||
return
|
||||
|
||||
d = self.get_valid_dict(convert_dates_to_str=True)
|
||||
d = self.get_valid_dict(convert_dates_to_str=True, ignore_nulls = self.doctype in ('DocType', 'DocField', 'DocPerm'))
|
||||
|
||||
# don't update name, as case might've been changed
|
||||
name = d['name']
|
||||
|
|
|
|||
|
|
@ -16,16 +16,17 @@ def add_comment(comment, comment_email, comment_by, reference_doctype, reference
|
|||
frappe.msgprint(_('Comment Should be atleast 10 characters'))
|
||||
return ''
|
||||
|
||||
blacklist = ['http://', 'https://', '@gmail.com']
|
||||
|
||||
if any([b in comment.content for b in blacklist]):
|
||||
frappe.msgprint(_('Comments cannot have links or email addresses'))
|
||||
return ''
|
||||
|
||||
comment = doc.add_comment(
|
||||
text = comment,
|
||||
comment_email = comment_email,
|
||||
comment_by = comment_by)
|
||||
|
||||
blacklist = ['http://', 'https://', '@gmail.com']
|
||||
|
||||
if not any([b in comment.content for b in blacklist]):
|
||||
# probably not spam!
|
||||
comment.db_set('published', 1)
|
||||
comment_by = comment_by,
|
||||
published = 1)
|
||||
|
||||
# since comments are embedded in the page, clear the web cache
|
||||
if route:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue