Browse Source

Transfere textos de documento e proposição para pasta private

pull/978/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
ef12da1598
  1. 20
      sapl/utils.py

20
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

Loading…
Cancel
Save