Browse Source

HOT-FIX: Refactorings

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

3
sapl/materia/forms.py

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

3
sapl/norma/forms.py

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

9
sapl/norma/views.py

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

Loading…
Cancel
Save