22
22
EM_TRAMITACAO = [(1 , 'Sim' ),
23
23
(0 , 'Não' )]
24
24
25
-
26
25
def grupo_autor ():
27
26
try :
28
27
grupo = Group .objects .get (name = 'Autor' )
29
28
except Group .DoesNotExist :
30
29
return None
31
30
return grupo .id
32
31
33
-
34
32
@reversion .register ()
35
33
class TipoProposicao (models .Model ):
36
34
descricao = models .CharField (max_length = 50 , verbose_name = _ ('Descrição' ))
@@ -120,10 +118,15 @@ def __str__(self):
120
118
TIPO_APRESENTACAO_CHOICES = Choices (('O' , 'oral' , _ ('Oral' )),
121
119
('E' , 'escrita' , _ ('Escrita' )))
122
120
121
+ def materia_upload_path (instance , filename ):
122
+ return texto_upload_path (instance , filename , subpath = instance .ano )
123
123
124
+ def anexo_upload_path (instance , filename ):
125
+ return texto_upload_path (instance , filename , subpath = instance .materia .ano )
126
+
124
127
@reversion .register ()
125
128
class MateriaLegislativa (models .Model ):
126
-
129
+
127
130
tipo = models .ForeignKey (TipoMateriaLegislativa ,
128
131
on_delete = models .PROTECT ,
129
132
verbose_name = _ ('Tipo' ))
@@ -194,7 +197,7 @@ class MateriaLegislativa(models.Model):
194
197
texto_original = models .FileField (
195
198
blank = True ,
196
199
null = True ,
197
- upload_to = texto_upload_path ,
200
+ upload_to = materia_upload_path ,
198
201
verbose_name = _ ('Texto Original' ),
199
202
validators = [restringe_tipos_de_arquivo_txt ])
200
203
@@ -215,6 +218,7 @@ class Meta:
215
218
def __str__ (self ):
216
219
return _ ('%(tipo)s nº %(numero)s de %(ano)s' ) % {
217
220
'tipo' : self .tipo , 'numero' : self .numero , 'ano' : self .ano }
221
+
218
222
219
223
def data_entrada_protocolo (self ):
220
224
'''
@@ -231,7 +235,7 @@ def data_entrada_protocolo(self):
231
235
pass
232
236
233
237
return ''
234
-
238
+
235
239
def delete (self , using = None , keep_parents = False ):
236
240
if self .texto_original :
237
241
self .texto_original .delete ()
@@ -255,6 +259,7 @@ def save(self, force_insert=False, force_update=False, using=None,
255
259
force_update = force_update ,
256
260
using = using ,
257
261
update_fields = update_fields )
262
+
258
263
259
264
260
265
@reversion .register ()
@@ -392,7 +397,7 @@ class DocumentoAcessorio(models.Model):
392
397
arquivo = models .FileField (
393
398
blank = True ,
394
399
null = True ,
395
- upload_to = texto_upload_path ,
400
+ upload_to = anexo_upload_path ,
396
401
verbose_name = _ ('Texto Integral' ),
397
402
validators = [restringe_tipos_de_arquivo_txt ])
398
403
@@ -625,7 +630,7 @@ class Proposicao(models.Model):
625
630
('I' , 'Incorporada' )),
626
631
verbose_name = _ ('Status Proposição' ))
627
632
texto_original = models .FileField (
628
- upload_to = texto_upload_path ,
633
+ upload_to = materia_upload_path ,
629
634
blank = True ,
630
635
null = True ,
631
636
verbose_name = _ ('Texto Original' ),
0 commit comments