From deafb772eeedb2da02e5a6a9ed0aa65db0bae21b Mon Sep 17 00:00:00 2001 From: Cesar Augusto de Carvalho Date: Mon, 3 Dec 2018 11:41:32 -0200 Subject: [PATCH] =?UTF-8?q?Fix=20#2380=20Cron=C3=B4metro=20n=C3=A3o=20acei?= =?UTF-8?q?ta=20valor=20acima=20de=2023:59=20(#2401)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #2380 * fix 2380 * fix 2380 * fix 2380 * fix #2380 --- .../migrations/0024_auto_20181126_1534.py | 35 +++++++++++++++++++ .../migrations/0025_auto_20181126_1648.py | 21 +++++++++++ .../migrations/0026_auto_20181126_1727.py | 20 +++++++++++ sapl/base/models.py | 8 ++--- sapl/base/templatetags/common_tags.py | 7 ++-- sapl/painel/views.py | 1 - sapl/sessao/views.py | 17 +++------ sapl/static/js/app.js | 2 +- 8 files changed, 88 insertions(+), 23 deletions(-) create mode 100644 sapl/base/migrations/0024_auto_20181126_1534.py create mode 100644 sapl/base/migrations/0025_auto_20181126_1648.py create mode 100644 sapl/base/migrations/0026_auto_20181126_1727.py diff --git a/sapl/base/migrations/0024_auto_20181126_1534.py b/sapl/base/migrations/0024_auto_20181126_1534.py new file mode 100644 index 000000000..2f91af1ea --- /dev/null +++ b/sapl/base/migrations/0024_auto_20181126_1534.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.8 on 2018-11-26 17:34 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0023_auto_20181105_1804'), + ] + + operations = [ + migrations.AlterField( + model_name='appconfig', + name='cronometro_aparte', + field=models.DurationField(blank=True, null=True, verbose_name='Cronômetro do Aparte'), + ), + migrations.AlterField( + model_name='appconfig', + name='cronometro_consideracoes', + field=models.DurationField(blank=True, null=True, verbose_name='Cronômetro de Considerações Finais'), + ), + migrations.AlterField( + model_name='appconfig', + name='cronometro_discurso', + field=models.DurationField(blank=True, null=True, verbose_name='Cronômetro do Discurso'), + ), + migrations.AlterField( + model_name='appconfig', + name='cronometro_ordem', + field=models.DurationField(blank=True, null=True, verbose_name='Cronômetro da Ordem'), + ), + ] diff --git a/sapl/base/migrations/0025_auto_20181126_1648.py b/sapl/base/migrations/0025_auto_20181126_1648.py new file mode 100644 index 000000000..a1ca53ed4 --- /dev/null +++ b/sapl/base/migrations/0025_auto_20181126_1648.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.8 on 2018-11-26 18:48 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0024_auto_20181126_1534'), + ] + + operations = [ + migrations.AlterField( + model_name='appconfig', + name='cronometro_discurso', + field=models.DurationField(blank=True, default=datetime.timedelta(0, 2400), null=True, verbose_name='Cronômetro do Discurso'), + ), + ] diff --git a/sapl/base/migrations/0026_auto_20181126_1727.py b/sapl/base/migrations/0026_auto_20181126_1727.py new file mode 100644 index 000000000..4b908e7c4 --- /dev/null +++ b/sapl/base/migrations/0026_auto_20181126_1727.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.8 on 2018-11-26 19:27 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0025_auto_20181126_1648'), + ] + + operations = [ + migrations.AlterField( + model_name='appconfig', + name='cronometro_discurso', + field=models.DurationField(blank=True, null=True, verbose_name='Cronômetro do Discurso'), + ), + ] diff --git a/sapl/base/models.py b/sapl/base/models.py index 9153803b8..5caf8b2c0 100644 --- a/sapl/base/models.py +++ b/sapl/base/models.py @@ -121,22 +121,22 @@ class AppConfig(models.Model): verbose_name=_('Quem deve assina a ata'), max_length=1, choices=ASSINATURA_ATA_CHOICES, default='T') - cronometro_discurso = models.TimeField( + cronometro_discurso = models.DurationField( verbose_name=_('Cronômetro do Discurso'), blank=True, null=True) - cronometro_aparte = models.TimeField( + cronometro_aparte = models.DurationField( verbose_name=_('Cronômetro do Aparte'), blank=True, null=True) - cronometro_ordem = models.TimeField( + cronometro_ordem = models.DurationField( verbose_name=_('Cronômetro da Ordem'), blank=True, null=True) - cronometro_consideracoes = models.TimeField( + cronometro_consideracoes = models.DurationField( verbose_name=_('Cronômetro de Considerações Finais'), blank=True, null=True) diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 4251e54da..89f781558 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -228,11 +228,8 @@ def file_extension(value): def cronometro_to_seconds(value): if not AppConfig.attr('cronometro_' + value): return 0 - - m, s, x = AppConfig.attr( - 'cronometro_' + value).isoformat().split(':') - - return 60 * int(m) + int(s) + + return AppConfig.attr('cronometro_' + value).seconds @register.filter diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 963e53019..333c3771e 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -340,7 +340,6 @@ def cronometro_painel(request): def get_cronometro_status(request, name): logger = logging.getLogger(__name__) username = request.user.username - try: logger.debug("user=" + username + ". Tentando obter cronometro.") cronometro = request.session[name] diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 08336c8a4..c674ea664 100755 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -846,18 +846,11 @@ class PainelView(PermissionRequiredForAppCrudMixin, TemplateView): messages.add_message(self.request, messages.ERROR, msg) else: - m, s, x = cronometro_discurso.isoformat().split(':') - cronometro_discurso = int(m) * 60 + int(s) - - m, s, x = cronometro_aparte.isoformat().split(':') - cronometro_aparte = int(m) * 60 + int(s) - - m, s, x = cronometro_ordem.isoformat().split(':') - cronometro_ordem = int(m) * 60 + int(s) - - m, s, x = cronometro_consideracoes.isoformat().split(':') - cronometro_consideracoes = int(m) * 60 + int(s) - + cronometro_discurso = cronometro_discurso.seconds + cronometro_aparte = cronometro_aparte.seconds + cronometro_ordem = cronometro_ordem.seconds + cronometro_consideracoes = cronometro_consideracoes.seconds + context = TemplateView.get_context_data(self, **kwargs) context.update({ 'head_title': str(_('Painel Plenário')), diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js index cc9c773ce..4341cb784 100644 --- a/sapl/static/js/app.js +++ b/sapl/static/js/app.js @@ -47,7 +47,7 @@ function refreshMask() { $('.dateinput').mask('00/00/0000', {placeholder:"__/__/____"}); $('.hora').mask("00:00", {placeholder:"hh:mm"}); $('.hora_hms').mask("00:00:00", {placeholder:"hh:mm:ss"}); - $('.cronometro').mask("00:00", {placeholder:"mm:ss"}); + $('.cronometro').mask("00:00:00", {placeholder:"hh:mm:ss"}); } function autorModal() {