From 05650a1bfd7a9cbdd1bab22a98db4feb30be5316 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Wed, 20 Apr 2016 10:35:06 -0300 Subject: [PATCH] Fix #335 Muda classe para sapl utils --- base/forms.py | 8 ++------ parlamentares/forms.py | 8 ++------ sapl/utils.py | 5 +++++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/base/forms.py b/base/forms.py index 4df29cdf1..6b05ee59b 100644 --- a/base/forms.py +++ b/base/forms.py @@ -4,19 +4,15 @@ from django import forms from django.core.exceptions import ValidationError from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ -from floppyforms import ClearableFileInput import crispy_layout_mixin +import sapl from crispy_layout_mixin import form_actions from sapl.settings import MAX_IMAGE_UPLOAD_SIZE from .models import CasaLegislativa -class ImageThumbnailFileInput(ClearableFileInput): - template_name = 'floppyforms/image_thumbnail.html' - - class CasaLegislativaTabelaAuxForm(ModelForm): class Meta: @@ -41,7 +37,7 @@ class CasaLegislativaTabelaAuxForm(ModelForm): 'cep': forms.TextInput(attrs={'class': 'cep'}), 'telefone': forms.TextInput(attrs={'class': 'telefone'}), 'fax': forms.TextInput(attrs={'class': 'telefone'}), - 'logotipo': ImageThumbnailFileInput, + 'logotipo': sapl.utils.ImageThumbnailFileInput, 'informacao_geral': forms.Textarea( attrs={'id': 'texto-rico'}) } diff --git a/parlamentares/forms.py b/parlamentares/forms.py index 11d6ad761..3df9ae69e 100644 --- a/parlamentares/forms.py +++ b/parlamentares/forms.py @@ -4,24 +4,20 @@ from django import forms from django.db import transaction from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ -from floppyforms import ClearableFileInput import crispy_layout_mixin +import sapl from crispy_layout_mixin import form_actions from .models import Dependente, Filiacao, Legislatura, Mandato, Parlamentar -class ImageThumbnailFileInput(ClearableFileInput): - template_name = 'floppyforms/image_thumbnail.html' - - class ParlamentarForm(ModelForm): class Meta: model = Parlamentar exclude = [] - widgets = {'fotografia': ImageThumbnailFileInput, + widgets = {'fotografia': sapl.utils.ImageThumbnailFileInput, 'biografia': forms.Textarea( attrs={'id': 'texto-rico'})} diff --git a/sapl/utils.py b/sapl/utils.py index c2a7c5f68..a94d7dfaf 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -6,6 +6,7 @@ from django.apps import apps from django.contrib import admin from django.core.exceptions import ValidationError from django.utils.translation import ugettext_lazy as _ +from floppyforms import ClearableFileInput 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): appname = module_name.split('.')[0] app = apps.get_app_config(appname)