Пример #1
0
def editar_discussao_caso_clinico(request, id, graph):
	context = RequestContext(request)
	resolve = connect(request, graph)
	context['acao'] = "Editar caso clínico"

	discussion = Discussion.discussion.get(id=id)

	if request.method == 'POST':
		form = NewCaseForm(request.POST, instance=discussion)
		if form.is_valid():
			form.save()

			for file in request.FILES.getlist('archive_description'):
				image_title = discussion.title + '-' + "nucao-uefs" + '-' + time.ctime().replace(':', '-')
				image_watermark = set_watermark(file)
				doc = image_to_file_field(image_watermark, image_title)

				# doc = Archive(archive=file)
				# doc.save()

				discussion.files.add(doc)

			for file in request.FILES.getlist('archive_exams'):
				doc = Archive(archive=file)
				doc.save()

				discussion.files_exams.add(doc)

			for file in request.FILES.getlist('archive_diagnosis'):
				doc = Archive(archive=file)
				doc.save()

				discussion.files_diagnosis.add(doc)

			for file in request.FILES.getlist('archive_conduta'):
				doc = Archive(archive=file)
				doc.save()

				discussion.files_treatment.add(doc)

			return HttpResponseRedirect(reverse('ver_discussao', args=[id, discussion.slug]))
	else:
		context['form'] = NewCaseForm(instance=discussion)
		context['theme'] = discussion.theme

		return render_to_response('novo_caso_clinico.html', context)
Пример #2
0
def novo_caso_clinico(request, graph):
	context = RequestContext(request)
	resolve = connect(request, graph)
	context['acao'] = "Novo caso clínico"

	if request.method == 'POST':
		form = NewCaseForm(request.POST)

		if form.is_valid():
			title = form.cleaned_data['title']
			description = form.cleaned_data['description']
			diagnosis = form.cleaned_data['diagnosis']
			treatment = form.cleaned_data['treatment']
			exams = form.cleaned_data['exams']
			subject = form.cleaned_data['subject']
			#theme = form.cleaned_data['theme']
			is_public = form.cleaned_data['is_public']

			theme = Theme.theme.create_theme(request.POST['theme'])

			discussion = create_discussion(request.user, title, theme, subject,
				description, diagnosis, treatment, exams, is_public, False, False)

			# archive = Archive(archive=request.FILES['archive'])
			# archive.save()
			# discussoes.files.add(archive)
			# print request.FILES
			from cStringIO import StringIO
			from django.core.files.base import ContentFile
			i = 0
			for file in request.FILES.getlist('archive_description'):
				# adm = User.objects.get(email="*****@*****.**")
				# doc = None
				# if request.user == adm:
				image_title = title + '-' + "nucao-uefs" + '-' + time.ctime().replace(':', '-')
				image_watermark = set_watermark(file)
				doc = image_to_file_field(image_watermark, image_title)
				# else:
				# 	doc = Archive(archive=file)
				# 	doc.save()

				discussion.files.add(doc)

			for file in request.FILES.getlist('archive_exams'):
				doc = Archive(archive=file)
				doc.save()

				discussion.files_exams.add(doc)

			for file in request.FILES.getlist('archive_diagnosis'):
				doc = Archive(archive=file)
				doc.save()

				discussion.files_diagnosis.add(doc)

			for file in request.FILES.getlist('archive_conduta'):
				doc = Archive(archive=file)
				doc.save()

				discussion.files_treatment.add(doc)

			discussion.save()

			#return render_to_response('ver_discussao.html', context)
			return HttpResponseRedirect(reverse('ver_discussao', args=[discussion.id, discussion.slug]))
	else:
		context['form']= NewCaseForm()

		return render_to_response('novo_caso_clinico.html', context)