Browse Source

Fix #335 Muda classe para sapl utils

pull/336/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
committed by Edward Ribeiro
parent
commit
05650a1bfd
  1. 8
      base/forms.py
  2. 8
      parlamentares/forms.py
  3. 5
      sapl/utils.py

8
base/forms.py

@ -4,19 +4,15 @@ from django import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from floppyforms import ClearableFileInput
import crispy_layout_mixin import crispy_layout_mixin
import sapl
from crispy_layout_mixin import form_actions from crispy_layout_mixin import form_actions
from sapl.settings import MAX_IMAGE_UPLOAD_SIZE from sapl.settings import MAX_IMAGE_UPLOAD_SIZE
from .models import CasaLegislativa from .models import CasaLegislativa
class ImageThumbnailFileInput(ClearableFileInput):
template_name = 'floppyforms/image_thumbnail.html'
class CasaLegislativaTabelaAuxForm(ModelForm): class CasaLegislativaTabelaAuxForm(ModelForm):
class Meta: class Meta:
@ -41,7 +37,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm):
'cep': forms.TextInput(attrs={'class': 'cep'}), 'cep': forms.TextInput(attrs={'class': 'cep'}),
'telefone': forms.TextInput(attrs={'class': 'telefone'}), 'telefone': forms.TextInput(attrs={'class': 'telefone'}),
'fax': forms.TextInput(attrs={'class': 'telefone'}), 'fax': forms.TextInput(attrs={'class': 'telefone'}),
'logotipo': ImageThumbnailFileInput, 'logotipo': sapl.utils.ImageThumbnailFileInput,
'informacao_geral': forms.Textarea( 'informacao_geral': forms.Textarea(
attrs={'id': 'texto-rico'}) attrs={'id': 'texto-rico'})
} }

8
parlamentares/forms.py

@ -4,24 +4,20 @@ from django import forms
from django.db import transaction from django.db import transaction
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from floppyforms import ClearableFileInput
import crispy_layout_mixin import crispy_layout_mixin
import sapl
from crispy_layout_mixin import form_actions from crispy_layout_mixin import form_actions
from .models import Dependente, Filiacao, Legislatura, Mandato, Parlamentar from .models import Dependente, Filiacao, Legislatura, Mandato, Parlamentar
class ImageThumbnailFileInput(ClearableFileInput):
template_name = 'floppyforms/image_thumbnail.html'
class ParlamentarForm(ModelForm): class ParlamentarForm(ModelForm):
class Meta: class Meta:
model = Parlamentar model = Parlamentar
exclude = [] exclude = []
widgets = {'fotografia': ImageThumbnailFileInput, widgets = {'fotografia': sapl.utils.ImageThumbnailFileInput,
'biografia': forms.Textarea( 'biografia': forms.Textarea(
attrs={'id': 'texto-rico'})} attrs={'id': 'texto-rico'})}

5
sapl/utils.py

@ -6,6 +6,7 @@ from django.apps import apps
from django.contrib import admin from django.contrib import admin
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from floppyforms import ClearableFileInput
autor_label = ''' autor_label = '''
@ -33,6 +34,10 @@ autor_modal = '''
''' '''
class ImageThumbnailFileInput(ClearableFileInput):
template_name = 'floppyforms/image_thumbnail.html'
def register_all_models_in_admin(module_name): def register_all_models_in_admin(module_name):
appname = module_name.split('.')[0] appname = module_name.split('.')[0]
app = apps.get_app_config(appname) app = apps.get_app_config(appname)

Loading…
Cancel
Save