From 95572bb266589bf1489b4c42a734a32eb39ebaac Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Mon, 11 Jan 2016 00:25:08 -0200 Subject: [PATCH] Closed issue #68 --- compilacao/forms.py | 22 ++++++--- .../migrations/0042_auto_20160110_1620.py | 47 +++++++++++++++++++ .../migrations/0043_auto_20160110_1733.py | 19 ++++++++ compilacao/models.py | 12 +++-- compilacao/views.py | 5 +- static/styles/app.scss | 2 +- templates/base.html | 7 +-- templates/compilacao/publicacao_detail.html | 36 ++++++++------ templates/compilacao/publicacao_list.html | 2 + .../compilacao/textoarticulado_detail.html | 14 +++--- 10 files changed, 127 insertions(+), 39 deletions(-) create mode 100644 compilacao/migrations/0042_auto_20160110_1620.py create mode 100644 compilacao/migrations/0043_auto_20160110_1733.py diff --git a/compilacao/forms.py b/compilacao/forms.py index f5ae76626..e6b9ab3b4 100644 --- a/compilacao/forms.py +++ b/compilacao/forms.py @@ -364,6 +364,11 @@ class PublicacaoForm(ModelForm): format='%d/%m/%Y'), error_messages=error_messages ) + hora = forms.TimeField( + label=Publicacao._meta.get_field('hora').verbose_name, + required=False, + widget=forms.TextInput( + attrs={'class': 'hora_hms'})) numero = forms.IntegerField( label=Publicacao._meta.get_field( 'numero').verbose_name, @@ -392,6 +397,7 @@ class PublicacaoForm(ModelForm): 'veiculo_publicacao', 'url_externa', 'data', + 'hora', 'numero', 'ano', 'edicao', @@ -402,24 +408,28 @@ class PublicacaoForm(ModelForm): def __init__(self, *args, **kwargs): row1 = to_row([ - ('tipo_publicacao', 3), - ('data', 3), + ('tipo_publicacao', 4), + ('veiculo_publicacao', 6), ('ano', 2), + ]) + + row2 = to_row([ + ('data', 4), + ('hora', 4), ('numero', 2), ('edicao', 2), ]) - row2 = to_row([ - ('veiculo_publicacao', 3), + row3 = to_row([ ('pagina_inicio', 2), ('pagina_fim', 2), - ('url_externa', 5), + ('url_externa', 8), ]) self.helper = FormHelper() self.helper.layout = FormLayout( Fieldset(Publicacao._meta.verbose_name, - row1, row2, css_class="large-12")) + row1, row2, row3, css_class="large-12")) super(PublicacaoForm, self).__init__(*args, **kwargs) pass diff --git a/compilacao/migrations/0042_auto_20160110_1620.py b/compilacao/migrations/0042_auto_20160110_1620.py new file mode 100644 index 000000000..97e2396cc --- /dev/null +++ b/compilacao/migrations/0042_auto_20160110_1620.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import datetime + +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0041_auto_20160109_1928'), + ] + + operations = [ + migrations.AddField( + model_name='publicacao', + name='hora', + field=models.TimeField(default=datetime.datetime( + 2016, 1, 10, 18, 20, 1, 151209, tzinfo=utc), verbose_name='Horário de Publicação'), + preserve_default=False, + ), + migrations.AlterField( + model_name='publicacao', + name='ano', + field=models.PositiveIntegerField( + verbose_name='Ano', blank=True, null=True), + ), + migrations.AlterField( + model_name='publicacao', + name='data', + field=models.DateField(verbose_name='Data de Publicação'), + ), + migrations.AlterField( + model_name='publicacao', + name='edicao', + field=models.PositiveIntegerField( + verbose_name='Edição', blank=True, null=True), + ), + migrations.AlterField( + model_name='publicacao', + name='numero', + field=models.PositiveIntegerField( + verbose_name='Número', blank=True, null=True), + ), + ] diff --git a/compilacao/migrations/0043_auto_20160110_1733.py b/compilacao/migrations/0043_auto_20160110_1733.py new file mode 100644 index 000000000..94261c8bf --- /dev/null +++ b/compilacao/migrations/0043_auto_20160110_1733.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', '0042_auto_20160110_1620'), + ] + + operations = [ + migrations.AlterField( + model_name='publicacao', + name='hora', + field=models.TimeField(null=True, verbose_name='Horário de Publicação', blank=True), + ), + ] diff --git a/compilacao/models.py b/compilacao/models.py index 0e0c4d6fd..88494093f 100644 --- a/compilacao/models.py +++ b/compilacao/models.py @@ -420,7 +420,7 @@ class TipoPublicacao(models.Model): verbose_name_plural = _('Tipos de Publicação') def __str__(self): - return self.sigla + ' - ' + self.nome + return self.nome class VeiculoPublicacao(models.Model): @@ -444,7 +444,9 @@ class Publicacao(TimestampedMixin): tipo_publicacao = models.ForeignKey( TipoPublicacao, verbose_name=_('Tipo de Publicação')) - data = models.DateTimeField(verbose_name=_('Data de Publicação')) + data = models.DateField(verbose_name=_('Data de Publicação')) + hora = models.TimeField( + blank=True, null=True, verbose_name=_('Horário de Publicação')) numero = models.PositiveIntegerField( blank=True, null=True, verbose_name=_('Número')) @@ -469,10 +471,10 @@ class Publicacao(TimestampedMixin): verbose_name_plural = _('Publicações') def __str__(self): - return '%s\n%s: %s' % ( - self.ta, + return _('%s realizada em %s \n %s') % ( self.tipo_publicacao, - defaultfilters.date(self.data, "d \d\e F \d\e Y")) + defaultfilters.date(self.data, "d \d\e F \d\e Y"), + self.ta) class Dispositivo(BaseModel, TimestampedMixin): diff --git a/compilacao/views.py b/compilacao/views.py index acc8b20d3..fd137838b 100644 --- a/compilacao/views.py +++ b/compilacao/views.py @@ -1552,7 +1552,7 @@ class PublicacaoListView(ListView): @property def title(self): - return _('%s de %s' % ( + return _('%s da %s' % ( self.model._meta.verbose_name_plural, self.ta)) @@ -1641,4 +1641,5 @@ class PublicacaoDeleteView(CompMixin, DeleteView): 'ta_id': self.kwargs['ta_id']}) def get_success_url(self): - return reverse_lazy('ta_pub_list') + return reverse_lazy('ta_pub_list', + kwargs={'ta_id': self.kwargs['ta_id']}) diff --git a/static/styles/app.scss b/static/styles/app.scss index cf3b64f0b..884572eb1 100644 --- a/static/styles/app.scss +++ b/static/styles/app.scss @@ -175,7 +175,7 @@ position: relative; display: table; width: 100%; height: 100%; -background-color: #fafafa; +background-color: #e9eaed; color: #444444; } diff --git a/templates/base.html b/templates/base.html index be0d7b45d..503b3bbfb 100644 --- a/templates/base.html +++ b/templates/base.html @@ -88,12 +88,12 @@ --> - + {% endblock actions %} - + {% block detail_content %} {# TODO replace fieldset for something semantically correct, but with similar visual grouping style #}