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)
def update_publish(request): XMLdata.update_publish(request.GET['result_id']) resource = XMLdata.get(request.GET['result_id']) # Send mail to the user and the admin context = {'URI': MDCS_URI, 'title': resource['title'], 'publicationdate': resource['publicationdate'], 'user': request.user.username} send_mail_to_managers(subject='Resource Published', pathToTemplate='dashboard/email/resource_published.html', context=context) return HttpResponse(json.dumps({}), content_type='application/javascript')
def update_publish(request): XMLdata.update_publish(request.GET['result_id']) resource = XMLdata.get(request.GET['result_id']) # Send mail to the user and the admin context = { 'URI': MDCS_URI, 'title': resource['title'], 'publicationdate': resource['publicationdate'], 'user': request.user.username } send_mail_to_managers( subject='Resource Published', pathToTemplate='dashboard/email/resource_published.html', context=context) return HttpResponse(json.dumps({}), content_type='application/javascript')
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)