Browse Source

HOT-FIX: Refactorings

pull/2160/head
Edward Ribeiro 6 years ago
parent
commit
4310589f6a
  1. 9
      sapl/materia/forms.py
  2. 9
      sapl/norma/forms.py
  3. 9
      sapl/norma/views.py

9
sapl/materia/forms.py

@ -1295,12 +1295,11 @@ class ProposicaoForm(forms.ModelForm):
def clean_texto_original(self):
texto_original = self.cleaned_data.get('texto_original', False)
if texto_original:
if texto_original.size > MAX_DOC_UPLOAD_SIZE:
max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024))
raise ValidationError(
if texto_original and texto_original.size > MAX_DOC_UPLOAD_SIZE:
max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024))
raise ValidationError(
"Arquivo muito grande. ( > {0}MB )".format(max_size))
return texto_original
return texto_original
def gerar_hash(self, inst, receber_recibo):

9
sapl/norma/forms.py

@ -164,11 +164,10 @@ class NormaJuridicaForm(ModelForm):
def clean_texto_integral(self):
texto_integral = self.cleaned_data.get('texto_integral', False)
if texto_integral:
if texto_integral.size > MAX_DOC_UPLOAD_SIZE:
max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024))
raise ValidationError(
"Arquivo muito grande. ( > {0}MB )".format(max_size))
if texto_integral and texto_integral.size > MAX_DOC_UPLOAD_SIZE:
max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024))
raise ValidationError(
"Arquivo muito grande. ( > {0}MB )".format(max_size))
return texto_integral
def save(self, commit=False):

9
sapl/norma/views.py

@ -110,15 +110,16 @@ class AnexoNormaJuridicaCrud(MasterDetailCrud):
class CreateView(MasterDetailCrud.CreateView):
form_class = AnexoNormaJuridicaForm
layout_key = 'AnexoNormaJuridica'
def get_initial(self):
norma_id = str(self.request).split("/")[-3]
self.initial = super(MasterDetailCrud.CreateView, self).get_initial()
self.initial['norma'] = NormaJuridica.objects.get(id=norma_id)
return self.initial
initial = super(MasterDetailCrud.CreateView, self).get_initial()
initial['norma'] = NormaJuridica.objects.get(id=self.kwargs['pk'])
return initial
class UpdateView(MasterDetailCrud.UpdateView):
form_class = AnexoNormaJuridicaForm
layout_key = 'AnexoNormaJuridica'
def get_initial(self):
initial = super(UpdateView, self).get_initial()
initial['norma'] = self.object.norma

Loading…
Cancel
Save