本文整理汇总了Python中mgi.models.XMLdata.update_publish_draft方法的典型用法代码示例。如果您正苦于以下问题:Python XMLdata.update_publish_draft方法的具体用法?Python XMLdata.update_publish_draft怎么用?Python XMLdata.update_publish_draft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mgi.models.XMLdata
的用法示例。
在下文中一共展示了XMLdata.update_publish_draft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_publish_draft
# 需要导入模块: from mgi.models import XMLdata [as 别名]
# 或者: from mgi.models.XMLdata import update_publish_draft [as 别名]
def update_publish_draft(request):
form_id = request.GET['draft_id']
form_data = FormData.objects.get(pk=form_id)
xml_string = form_data.xml_data
title = form_data.name
if xml_string == "" or xml_string is None:
return HttpResponseBadRequest('No XML data found')
try:
# update form data if id is present
if form_data.xml_data_id is not None:
publicationdate = XMLdata.update_publish_draft(form_data.xml_data_id, xml_string, str(request.user.id))
#Delete the form
if form_data.schema_element_root is not None:
delete_branch_from_db(form_data.schema_element_root.pk)
form_data.delete()
# Send mail to the managers
context = {'URI': MDCS_URI,
'title': title,
'publicationdate': publicationdate,
'user': request.user.username}
send_mail_to_managers(subject='Resource Published',
pathToTemplate='dashboard/email/resource_published.html',
context=context)
messages.add_message(request, messages.INFO, 'New version published with success.')
return HttpResponse(json.dumps({}), content_type='application/javascript')
else:
return HttpResponseBadRequest('Related record not found. Impossible to publish the draft')
except Exception, e:
message = e.message.replace('"', '\'')
return HttpResponseBadRequest(message)