From ef12da1598d64e4cffd114ee8de2f985419dabd4 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 28 Mar 2017 14:41:15 -0300 Subject: [PATCH] =?UTF-8?q?Transfere=20textos=20de=20documento=20e=20propo?= =?UTF-8?q?si=C3=A7=C3=A3o=20para=20pasta=20private?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/utils.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sapl/utils.py b/sapl/utils.py index d957add71..c40160958 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -608,10 +608,20 @@ def texto_upload_path(instance, filename, subpath=''): filename = re.sub('[^a-zA-Z0-9.]', '-', filename).strip('-').lower() filename = re.sub('[-]+', '-', filename) - path = './sapl/%(model_name)s/%(pk)s/%(subpath)s%(filename)s' % { - 'model_name': instance._meta.model_name, - 'pk': instance.pk, - 'subpath': subpath, - 'filename': filename} + prefix = 'public' + + from sapl.materia.models import Proposicao + from sapl.protocoloadm.models import DocumentoAdministrativo + if isinstance(instance, (DocumentoAdministrativo, Proposicao)): + prefix = 'private' + + path = './sapl/%(prefix)s/%(model_name)s/%(pk)s/%(subpath)s%(filename)s' %\ + { + 'prefix': prefix, + 'model_name': instance._meta.model_name, + 'pk': instance.pk, + 'subpath': subpath, + 'filename': filename + } return path