[fix] [patch] [minor] make notes
This commit is contained in:
parent
d491012009
commit
26c3240b67
@ -13,17 +13,27 @@ def execute():
|
|||||||
name = question.question[:180]
|
name = question.question[:180]
|
||||||
if webnotes.conn.exists("Note", name):
|
if webnotes.conn.exists("Note", name):
|
||||||
webnotes.delete_doc("Note", name)
|
webnotes.delete_doc("Note", name)
|
||||||
note = webnotes.bean({
|
|
||||||
|
similar_questions = webnotes.conn.sql_list("""select name from `tabQuestion`
|
||||||
|
where question like %s""", "%s%%" % name)
|
||||||
|
answers = [markdown2.markdown(c) for c in webnotes.conn.sql_list("""
|
||||||
|
select answer from tabAnswer where question in (%s)""" % \
|
||||||
|
", ".join(["%s"]*len(similar_questions)), similar_questions)]
|
||||||
|
|
||||||
|
webnotes.bean({
|
||||||
"doctype":"Note",
|
"doctype":"Note",
|
||||||
"title": name,
|
"title": name,
|
||||||
"content": "<hr>".join([markdown2.markdown(c) for c in webnotes.conn.sql_list("""
|
"content": "<hr>".join(answers),
|
||||||
select answer from tabAnswer where question=%s""", question.name)]),
|
|
||||||
"owner": question.owner,
|
"owner": question.owner,
|
||||||
"creation": question.creation,
|
"creation": question.creation,
|
||||||
"public": 1
|
"public": 1
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
except NameError:
|
except NameError:
|
||||||
pass
|
pass
|
||||||
|
except Exception, e:
|
||||||
|
if e.args[0] != 1062:
|
||||||
|
raise e
|
||||||
|
|
||||||
webnotes.delete_doc("DocType", "Question")
|
webnotes.delete_doc("DocType", "Question")
|
||||||
webnotes.delete_doc("DocType", "Answer")
|
webnotes.delete_doc("DocType", "Answer")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user