[minor] fixed patch

This commit is contained in:
Anand Doshi 2013-07-16 15:14:13 +05:30
parent 447068aefe
commit 526a60b517

View File

@ -6,18 +6,21 @@ def execute():
for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True): for question in webnotes.conn.sql("""select * from tabQuestion""", as_dict=True):
if question.question: if question.question:
name = question.question[:180] try:
if webnotes.conn.exists("Note", name): name = question.question[:180]
webnotes.delete_doc("Note", name) if webnotes.conn.exists("Note", name):
note = webnotes.bean({ webnotes.delete_doc("Note", name)
"doctype":"Note", note = webnotes.bean({
"title": name, "doctype":"Note",
"content": "<hr>".join([markdown2.markdown(c) for c in webnotes.conn.sql_list(""" "title": name,
select answer from tabAnswer where question=%s""", question.name)]), "content": "<hr>".join([markdown2.markdown(c) for c in webnotes.conn.sql_list("""
"owner": question.owner, select answer from tabAnswer where question=%s""", question.name)]),
"creation": question.creation, "owner": question.owner,
"public": 1 "creation": question.creation,
}).insert() "public": 1
}).insert()
except NameError:
pass
webnotes.delete_doc("DocType", "Question") webnotes.delete_doc("DocType", "Question")
webnotes.delete_doc("DocType", "Answer") webnotes.delete_doc("DocType", "Answer")