From 26c3240b67d45f029b5730721932aef70f34e65a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 23 Aug 2013 12:21:52 +0530 Subject: [PATCH] [fix] [patch] [minor] make notes --- patches/may_2013/p06_make_notes.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/patches/may_2013/p06_make_notes.py b/patches/may_2013/p06_make_notes.py index b60642c53e..29bfe25da4 100644 --- a/patches/may_2013/p06_make_notes.py +++ b/patches/may_2013/p06_make_notes.py @@ -13,17 +13,27 @@ def execute(): name = question.question[:180] if webnotes.conn.exists("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", "title": name, - "content": "
".join([markdown2.markdown(c) for c in webnotes.conn.sql_list(""" - select answer from tabAnswer where question=%s""", question.name)]), + "content": "
".join(answers), "owner": question.owner, "creation": question.creation, "public": 1 }).insert() + except NameError: pass + except Exception, e: + if e.args[0] != 1062: + raise e webnotes.delete_doc("DocType", "Question") webnotes.delete_doc("DocType", "Answer")