diff --git a/parlamentares/forms.py b/parlamentares/forms.py index 9a3c1ab3c..40d4c746e 100644 --- a/parlamentares/forms.py +++ b/parlamentares/forms.py @@ -4,6 +4,7 @@ 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 from crispy_layout_mixin import form_actions @@ -11,7 +12,19 @@ from crispy_layout_mixin import form_actions from .models import Dependente, Filiacao, Legislatura, Mandato, Parlamentar -class ParlamentarCreateForm(ModelForm): +class ImageThumbnailFileInput(ClearableFileInput): + template_name = 'floppyforms/image_thumbnail.html' + + +class ParlamentarForm(ModelForm): + + class Meta: + model = Parlamentar + exclude = [] + widgets = {'fotografia': ImageThumbnailFileInput} + + +class ParlamentarCreateForm(ParlamentarForm): legislatura = forms.ModelChoiceField( label=_('Legislatura'), @@ -25,10 +38,6 @@ class ParlamentarCreateForm(ModelForm): required=True, ) - class Meta: - model = Parlamentar - exclude = [] - @transaction.atomic def save(self, commit=True): parlamentar = super(ParlamentarCreateForm, self).save(commit) diff --git a/parlamentares/views.py b/parlamentares/views.py index 6caed3ec4..c0bb5d859 100644 --- a/parlamentares/views.py +++ b/parlamentares/views.py @@ -11,7 +11,7 @@ from crud.base import Crud from .forms import (DependenteEditForm, DependenteForm, FiliacaoEditForm, FiliacaoForm, MandatoEditForm, MandatoForm, - ParlamentarCreateForm) + ParlamentarCreateForm, ParlamentarForm) from .models import (CargoMesa, Coligacao, ComposicaoMesa, Dependente, Filiacao, Legislatura, Mandato, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, SituacaoMilitar, @@ -35,6 +35,9 @@ class ParlamentarCrud(Crud): model = Parlamentar help_path = '' + class UpdateView(crud.base.CrudUpdateView): + form_class = ParlamentarForm + class CreateView(crud.base.CrudCreateView): form_class = ParlamentarCreateForm diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index b69a855e8..6249b9de7 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -1,10 +1,13 @@ -r test-requirements.txt -autopep8 -beautifulsoup4 -django-debug-toolbar -django-extensions -flake8 -ipdb -isort -pygraphviz -pytest-ipdb==0.1-prerelease2 # nao instala sem fixar a versao +autopep8==1.2.2 +beautifulsoup4==4.4.1 +django-debug-toolbar==1.4 +django-extensions==1.6.1 +django-floppyforms==1.6.1 +easy-thumbnails==2.3 +flake8==2.5.4 +ipdb==0.9.0 +isort==4.2.2 +pygraphviz==1.3rc2 +pytest-ipdb==0.1-prerelease2 + diff --git a/sapl/settings.py b/sapl/settings.py index a9900084b..e0d02f524 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -59,6 +59,8 @@ INSTALLED_APPS = ( 'djangobower', 'bootstrap3', # basically for django_admin_bootstrapped 'crispy_forms', + 'easy_thumbnails', + 'floppyforms', 'sass_processor', 'rest_framework', diff --git a/static/img/perfil.png b/static/img/perfil.png new file mode 100644 index 000000000..d1c4b77ed Binary files /dev/null and b/static/img/perfil.png differ diff --git a/templates/floppyforms/image_thumbnail.html b/templates/floppyforms/image_thumbnail.html new file mode 100644 index 000000000..087f84860 --- /dev/null +++ b/templates/floppyforms/image_thumbnail.html @@ -0,0 +1,64 @@ +{% load i18n staticfiles thumbnail %} + +