def form_mensaje_proccesor(request):
	context={ "formMensaje" : mensajeForm(),
			  "formArchivo" : mediaForm(),
			  "formRP" : nombreRichPictureForm(),
			  "resumenForm" : resumenAnalisisForm(),
			  "formComentary" : comentaryForm(),
			  "formDR" : nombreDefinicionRaizForm(),
			  "formCATWOE" : catwoeForm(),
			  "formNDR" : addDefinicionRaizForm(),
	}
	return context
Example #2
0
def richPicture_crear_view(request, id_ssp):
	if members_only(id_ssp, request):
		if request.method == "POST":
			form = nombreRichPictureForm(request.POST)
			if form.is_valid():
				name_rp = form.cleaned_data['name_rp']
				newRP = RichPicture.objects.create(name_rp=name_rp, created_by=request.user.get_username())
				newRP.save()

				proyecto = userSoftSystemProject.objects.get(id=id_ssp)
				stateTwo = StateTwo.objects.get(ssp_stateTwo=proyecto)
				stateTwo.ssp_richPictures.append(newRP.id)
				stateTwo.save()
				
				notificar(id_ssp, request.user.id, '/verRichPicture/%s/%s'%(id_ssp,newRP.id), 'Agrego un nuevo Rich Picture', newRP.id, 'RichPicture')

				return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
			return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

	else:
		return render(request, 'comunicacion/error.html')
Example #3
0
def richPicture_newDocumento_view(request, id_ssp,id_rp):
	if request.method == "POST":
		form = nombreRichPictureForm(request.POST)
		if form.is_valid():
			storage = Storage(CredentialsModel, 'id_user', request.user, 'credential')
			credential = storage.get()
			if credential is None or credential.invalid:
				FLOW.params['state'] = xsrfutil.generate_token(settings.SECRET_KEY,request.user)
				authorize_url = FLOW.step1_get_authorize_url()
				return HttpResponseRedirect(authorize_url)
			else:
				proyecto = userSoftSystemProject.objects.get(id=id_ssp)
				name_documento = form.cleaned_data['name_rp']

				try:
					storage = Storage(CredentialsModel, 'id_user', request.user, 'credential')
					credential = storage.get()
					http = httplib2.Http()
					http = credential.authorize(http)
					drive_service = build('drive', 'v2', http=http, developerKey="hbP6_4UJIKe-m74yLd8tQDfT")
				except:
					return redirect('vista_logout')


				if request.user == proyecto.manager:
					body = {
					  'title': '%s'%(name_documento),
					  'description': 'Documento nuevo de %s'%(proyecto.name_ssp),
					  'mimeType': 'application/vnd.google-apps.drawing',
					  'parents' : [{'id' : proyecto.id_folder_ssp}],
					}
					try:
						file = drive_service.files().insert(body=body).execute()
					except:
						body = {
						  'title': '%s'%(name_documento),
						  'description': 'Documento nuevo de %s'%(proyecto.name_ssp),
						  'mimeType': 'application/vnd.google-apps.drawing',
						}
						try:
							file = drive_service.files().insert(body=body).execute()
						except:
							return render(request, 'comunicacion/error.html')

				else:

					userP = userProfile.objects.get(user=request.user)
					ID_final = ''
					for ID in userP.id_folder_user:
						if ID in proyecto.ids_folder_ssp:
							ID_final = ID
					body = {
					  'title': '%s'%(name_documento),
					  'description': 'Documento nuevo de %s'%(proyecto.name_ssp),
					  'mimeType': 'application/vnd.google-apps.drawing',
					  'parents' : [{'id' : ID_final}],
					}
					try:
						file = drive_service.files().insert(body=body).execute()
					except:
						
						body = {
						  'title': '%s'%(name_documento),
						  'description': 'Documento nuevo de %s'%(proyecto.name_ssp),
						  'mimeType': 'application/vnd.google-apps.drawing',
						}
						try:
							file = drive_service.files().insert(body=body).execute()
						except:
							return render(request, 'comunicacion/error.html')
							


				url_documento = file.get('alternateLink')
				newDocumento = DocumentoAnalisis.objects.create(name_documento=name_documento, url_documento=url_documento, shared_documento=request.user.get_username())
				newDocumento.save()

				richPicture = RichPicture.objects.get(id=id_rp)
				richPicture.documentos_rp.append(newDocumento.id)
				richPicture.save()
				return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
		return HttpResponseRedirect(request.META.get('HTTP_REFERER'))