diff --git a/compilacao/forms.py b/compilacao/forms.py index 46b899bb5..11bf4bc1d 100644 --- a/compilacao/forms.py +++ b/compilacao/forms.py @@ -9,6 +9,7 @@ from django.core.exceptions import NON_FIELD_ERRORS from django.forms.models import ModelForm from django.utils.translation import ugettext_lazy as _ +from compilacao import utils, models from compilacao.models import Dispositivo, Nota, TipoNota, TipoVide, Vide,\ TextoArticulado, TipoTextoArticulado from compilacao.utils import to_row, to_column @@ -56,6 +57,10 @@ class TaForm(ModelForm): widget=forms.Textarea, error_messages=ta_error_messages, required=False) + participacao_social = forms.NullBooleanField( + label=_('Participação Social'), + widget=forms.Select(choices=models.PARTICIPACAO_SOCIAL_CHOICES), + required=False) class Meta: model = TextoArticulado @@ -65,25 +70,27 @@ class TaForm(ModelForm): 'data', 'ementa', 'observacao', + 'participacao_social', ] def __init__(self, *args, **kwargs): row1 = to_row([ - ('tipo_ta', 5), + ('tipo_ta', 3), ('numero', 2), ('ano', 2), - ('data', 3), + ('data', 2), + ('participacao_social', 3), ]) self.helper = FormHelper() self.helper.layout = Layout( - row1, + Fieldset(_('Identificação Básica'), row1, css_class="large-12"), Fieldset(_('Ementa'), Column('ementa'), css_class="large-12"), Fieldset( _('Observações'), Column('observacao'), css_class="large-12"), ButtonHolder( - Submit('Save', 'Save', + Submit('submit', _('Salvar'), css_class='radius') ) ) diff --git a/compilacao/migrations/0036_auto_20151224_1341.py b/compilacao/migrations/0036_auto_20151224_1341.py new file mode 100644 index 000000000..a90b7861c --- /dev/null +++ b/compilacao/migrations/0036_auto_20151224_1341.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0035_auto_20151223_1709'), + ] + + operations = [ + migrations.AlterModelOptions( + name='textoarticulado', + options={'verbose_name': 'Texto Articulado', 'verbose_name_plural': 'Textos Articulados', 'ordering': ['-data', '-numero']}, + ), + migrations.AddField( + model_name='textoarticulado', + name='participacao_social', + field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], verbose_name='Participação Social', default=False), + ), + ] diff --git a/compilacao/migrations/0037_auto_20151224_1348.py b/compilacao/migrations/0037_auto_20151224_1348.py new file mode 100644 index 000000000..9e355c45e --- /dev/null +++ b/compilacao/migrations/0037_auto_20151224_1348.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0036_auto_20151224_1341'), + ] + + operations = [ + migrations.AlterField( + model_name='textoarticulado', + name='participacao_social', + field=models.NullBooleanField(verbose_name='Participação Social', choices=[(True, 'Sim'), (False, 'Não')], default=False), + ), + ] diff --git a/compilacao/migrations/0038_auto_20151224_1429.py b/compilacao/migrations/0038_auto_20151224_1429.py new file mode 100644 index 000000000..0e73bb987 --- /dev/null +++ b/compilacao/migrations/0038_auto_20151224_1429.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0037_auto_20151224_1348'), + ] + + operations = [ + migrations.AddField( + model_name='tipotextoarticulado', + name='participacao_social', + field=models.NullBooleanField(default=False, verbose_name='Participação Social', choices=[(True, 'Sim'), (False, 'Não')]), + ), + migrations.AlterField( + model_name='textoarticulado', + name='participacao_social', + field=models.NullBooleanField(default=None, verbose_name='Participação Social', choices=[(None, 'Padrão definido no Tipo'), (True, 'Sim'), (False, 'Não')]), + ), + ] diff --git a/compilacao/models.py b/compilacao/models.py index 8c213c57d..2835141b1 100644 --- a/compilacao/models.py +++ b/compilacao/models.py @@ -61,6 +61,11 @@ class BaseModel(models.Model): class TipoTextoArticulado(models.Model): sigla = models.CharField(max_length=3, verbose_name=_('Sigla')) descricao = models.CharField(max_length=50, verbose_name=_('Descrição')) + participacao_social = models.NullBooleanField( + default=False, + blank=True, null=True, + choices=utils.YES_NO_CHOICES, + verbose_name=_('Participação Social')) class Meta: verbose_name = _('Tipo de Texto Articulado') @@ -70,6 +75,12 @@ class TipoTextoArticulado(models.Model): return self.descricao +PARTICIPACAO_SOCIAL_CHOICES = [ + (None, _('Padrão definido no Tipo')), + (True, _('Sim')), + (False, _('Não'))] + + class TextoArticulado(TimestampedMixin): data = models.DateField(blank=True, null=True, verbose_name=_('Data')) ementa = models.TextField(verbose_name=_('Ementa')) @@ -80,6 +91,11 @@ class TextoArticulado(TimestampedMixin): tipo_ta = models.ForeignKey( TipoTextoArticulado, verbose_name=_('Tipo de Texto Articulado')) + participacao_social = models.NullBooleanField( + default=None, + blank=True, null=True, + choices=PARTICIPACAO_SOCIAL_CHOICES, + verbose_name=_('Participação Social')) class Meta: verbose_name = _('Texto Articulado') diff --git a/compilacao/urls.py b/compilacao/urls.py index 352f3931d..311c371a0 100644 --- a/compilacao/urls.py +++ b/compilacao/urls.py @@ -3,19 +3,17 @@ from django.conf.urls import include, url from compilacao import views urlpatterns_compilacao = [ - url(r'^$', views.TaListView.as_view(), name='ta_list'), + url(r'^create$', views.TaCreateView.as_view(), name='ta_create'), url(r'^(?P[0-9]+)$', views.TaDetailView.as_view(), name='ta_detail'), url(r'^(?P[0-9]+)/edit$', views.TaUpdateView.as_view(), name='ta_edit'), - + url(r'^(?P[0-9]+)/delete$', + views.TaDeleteView.as_view(), name='ta_delete'), ] urlpatterns = [ url(r'^ta/', include(urlpatterns_compilacao)), - - - ] diff --git a/compilacao/views.py b/compilacao/views.py index e3fb96522..b59cbd74b 100644 --- a/compilacao/views.py +++ b/compilacao/views.py @@ -2,6 +2,7 @@ from collections import OrderedDict from datetime import datetime, timedelta from os.path import sys +from braces.views import FormMessagesMixin from django.contrib.auth.decorators import login_required from django.contrib.messages.api import success from django.core.signing import Signer @@ -16,7 +17,8 @@ from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ from django.views.generic.base import TemplateView from django.views.generic.detail import DetailView -from django.views.generic.edit import FormMixin, UpdateView, CreateView +from django.views.generic.edit import FormMixin, UpdateView, CreateView,\ + DeleteView from django.views.generic.list import ListView from compilacao import forms, utils @@ -42,7 +44,9 @@ DISPOSITIVO_SELECT_RELATED = ( class TaListView(ListView): model = TextoArticulado paginate_by = 10 - title = TextoArticulado._meta.verbose_name_plural + verbose_name = model._meta.verbose_name + title = model._meta.verbose_name_plural + create_url = reverse_lazy('ta_create') def get_context_data(self, **kwargs): context = super(TaListView, self).get_context_data(**kwargs) @@ -61,6 +65,17 @@ class TaDetailView(DetailView): return self.get_object() +class TaCreateView(FormMessagesMixin, CreateView): + model = TextoArticulado + form_class = forms.TaForm + template_name = "compilacao/form.html" + form_valid_message = _('Registro criado com sucesso!') + form_invalid_message = _('O registro não foi criado.') + + def get_success_url(self): + return reverse_lazy('ta_detail', kwargs={'pk': self.object.id}) + + class TaUpdateView(UpdateView): model = TextoArticulado form_class = forms.TaForm @@ -72,3 +87,18 @@ class TaUpdateView(UpdateView): def get_success_url(self): return reverse_lazy('ta_detail', kwargs={'pk': self.kwargs['pk']}) + + +class TaDeleteView(DeleteView): + model = TextoArticulado + + @property + def title(self): + return self.get_object() + + @property + def detail_url(self): + return reverse_lazy('ta_detail', kwargs={'pk': self.kwargs['pk']}) + + def get_success_url(self): + return reverse_lazy('ta_list') diff --git a/norma/urls.py b/norma/urls.py index fb3110513..5d22d640e 100644 --- a/norma/urls.py +++ b/norma/urls.py @@ -5,7 +5,7 @@ from norma.views import (NormaIncluirView, assunto_norma_crud, norma_temporario_crud, tipo_norma_crud) -norma_url_patterns = norma_temporario_crud.urlpatterns +norma_url_patterns = norma_temporario_crud.urlpatterns + __url__compilacao # norma_url_patterns = norma_crud.urlpatterns + [] urlpatterns = [ diff --git a/sapl/settings.py b/sapl/settings.py index d47795f61..c3971715d 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -59,8 +59,8 @@ INSTALLED_APPS = ( 'crispy_forms_foundation', 'sass_processor', ) -if DEBUG: - INSTALLED_APPS += ('debug_toolbar',) +# if DEBUG: +# INSTALLED_APPS += ('debug_toolbar',) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', @@ -117,7 +117,7 @@ DATABASES = { # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'pt-br' TIME_ZONE = 'America/Sao_Paulo' -USE_I18N = False +USE_I18N = True USE_L10N = False USE_TZ = True # DATE_FORMAT = 'N j, Y' diff --git a/templates/compilacao/textoarticulado_confirm_delete.html b/templates/compilacao/textoarticulado_confirm_delete.html new file mode 100644 index 000000000..354db7f00 --- /dev/null +++ b/templates/compilacao/textoarticulado_confirm_delete.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block base_content %} +
{% csrf_token %} +
+ +

+ {% blocktrans %} + Confirma exclusão de
"{{ object }}"? + {% endblocktrans %} +

+ + +
+
+{% endblock %} diff --git a/templates/compilacao/textoarticulado_detail.html b/templates/compilacao/textoarticulado_detail.html index 64abc548f..321f51263 100644 --- a/templates/compilacao/textoarticulado_detail.html +++ b/templates/compilacao/textoarticulado_detail.html @@ -1,71 +1,61 @@ -{% extends "base.html" %} -{% load i18n %} -{% load compilacao_filters %} - -{% block base_content %} - - {# FIXME is this the best markup to use? #} -
+{% extends "base.html" %} {% load i18n %} {% load compilacao_filters %} {% block base_content %} {# FIXME is this the best markup to use? #} +
{% block actions %} -
- - {% block detail_content %} - {# TODO replace fieldset for something semantically correct, but with similar visual grouping style #} - -
- {%trans 'Identificação Básica'%} - -
- -
-
- -

{{ object.tipo_ta}}

-
-
- -
-
- -

{{ object.numero}}

-
-
- -
-
- -

{{ object.ano}}

-
-
- -
-
- -

{{ object.data}}

-
-
-
-
- -
-
- -

{{ object.ementa|safe}}

-
-
- -
- -
- - - - {% endblock detail_content %} - -{% endblock base_content %} +
{% trans 'Excluir' %}
+ + {% endblock actions %} {% block sections_nav %}{% endblock %} +
+ +{% block detail_content %} {# TODO replace fieldset for something semantically correct, but with similar visual grouping style #} + +
+ {%trans 'Identificação Básica'%} + +
+ +
+
+ +

{{ object.tipo_ta}}

+
+
+ +
+
+ +

{{ object.numero}}

+
+
+ +
+
+ +

{{ object.ano}}

+
+
+ +
+
+ +

{{ object.data}}

+
+
+
+
+
+
+
+ +

{{ object.ementa|safe}}

+
+
+ +
+ +
+ + + +{% endblock detail_content %} {% endblock base_content %} diff --git a/templates/compilacao/textoarticulado_list.html b/templates/compilacao/textoarticulado_list.html index 3e4632ff3..070ec3ff7 100644 --- a/templates/compilacao/textoarticulado_list.html +++ b/templates/compilacao/textoarticulado_list.html @@ -1,5 +1,17 @@ {% extends "base.html" %} {% load i18n %} {% block base_content %} + +{# FIXME is this the best markup to use? #} + + @@ -17,7 +29,7 @@ - + {% endfor %}
{{ ta.numero }} {{ ta.ano }} {{ ta.data }}{{ ta.ementa }}{{ ta.ementa|safe }}