From cc8315e5b79330f0cd899c2fd0be6b2c2af9ff5e Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 11 Apr 2016 10:36:34 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20preview=20de=20foto=20na=20adi=C3=A7?= =?UTF-8?q?=C3=A3o=20e=20edi=C3=A7=C3=A3o=20de=20parlamentar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parlamentares/forms.py | 19 ++++-- parlamentares/views.py | 5 +- requirements/dev-requirements.txt | 21 ++++--- sapl/settings.py | 2 + static/img/perfil.png | Bin 0 -> 6301 bytes templates/floppyforms/image_thumbnail.html | 64 +++++++++++++++++++++ 6 files changed, 96 insertions(+), 15 deletions(-) create mode 100644 static/img/perfil.png create mode 100644 templates/floppyforms/image_thumbnail.html 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 0000000000000000000000000000000000000000..d1c4b77edc683ab92335f294f95c9c7819933d8e GIT binary patch literal 6301 zcmV;O7-Hv%P)d?i*Lf+JwT=RUpcT1_y~9xSsXTr72U+T7Z~T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@kFV`8ptJLO)!CEY<~^RG}f(*(93`%r(bfcT}S;^K1_` zp~8b$D!Hx$R^wlwT@$`>5aZ$f7u$UO);nQq|5F zlYk=B5IX0B6PSW57DN@T?2e_V;TanmpSOUq$U+GhNfo{l>+BBxxwrEgLOHMiSv+7=eGbJ#qMxocWeL#hCP|;aHsdc zuM@bs5u}<9*ut4q;Z3Z%4l6|#KLG}#oip*ru%RaBEWqwKh~2RmyQ8;{0SzUYZp7|b zjoncOEJgbid3}5cboOqGx$E^&*dcO^-a3_WEASd>sHDcC1o#5@0C*o+R0ic)>;CS9 z8kuJ#a2@`w*?kQ>ge(doNySI*Y)VZI^#`<*VmE~Sz?Z0rhw_1~$l`dTNYaoEXLoc# zJ)oNjThr8}UP58M7HMYS~;0$UsW%rNN zZ5+@BNI?zZ)C1`2rxf)y%l!a&7+D;SL_$SAvCbtJz&v0yL|k~J9l$(f@lwRiYNM7| z+GOhr%mFR~+K1s2dQdaMFGm(p8PPC0<5S6EFEGlxO%&_3#Y#|j{X+o-HAl@3;4Wlg zMHZ<*)P~8FXb$+XYOyq#2w0&V?->L*ciB<}}y0-FJc*YI}(E@a`tgbCe + {% if field.label %} + + {% endif %} + +
+
+ {% if value.url %} +
+
+ {{ value }} +
+
+
+
+ + +
+
+ + {% else %} +
+
+ +
+
+ {% endif %} +
+
+
+ +
+
+
+ {% include 'bootstrap3/layout/help_text_and_errors.html' %} +
+