diff --git a/sapl/sdr/forms.py b/sapl/sdr/forms.py index 9d334cec9..57b0b47e9 100644 --- a/sapl/sdr/forms.py +++ b/sapl/sdr/forms.py @@ -4,6 +4,7 @@ from django import forms from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ from django.utils import timezone + from sapl.sdr.models import DeliberacaoRemota from sapl.sessao.models import SessaoPlenaria @@ -26,11 +27,12 @@ class DeliberacaoRemotaForm(ModelForm): widgets = { 'created_by': forms.HiddenInput(), + 'inicio': forms.HiddenInput(), } def clean(self): cleaned_data = super().clean() - + if not self.is_valid(): return self.cleaned_data @@ -42,60 +44,3 @@ class DeliberacaoRemotaForm(ModelForm): cleaned_data['termino'] = None return cleaned_data - - -# class DeliberacaoRemotaForm(ModelForm): -# -# logger = logging.getLogger(__name__) -# -# class Meta: -# model = DeliberacaoRemota -# fields = ['chat_id', 'descricao'] -# class AutoriaNormaForm(ModelForm): -# -# tipo_autor = ModelChoiceField(label=_('Tipo Autor'), -# required=False, -# queryset=TipoAutor.objects.all(), -# empty_label=_('Selecione'), ) -# -# data_relativa = forms.DateField( -# widget=forms.HiddenInput(), required=False) -# -# logger = logging.getLogger(__name__) -# -# def __init__(self, *args, **kwargs): -# super(AutoriaNormaForm, self).__init__(*args, **kwargs) -# -# row1 = to_row([('tipo_autor', 4), -# ('autor', 4), -# ('primeiro_autor', 4)]) -# -# self.helper = SaplFormHelper() -# self.helper.layout = Layout( -# Fieldset(_('Autoria'), -# row1, 'data_relativa', form_actions(label='Salvar'))) -# -# if not kwargs['instance']: -# self.fields['autor'].choices = [] -# -# class Meta: -# model = AutoriaNorma -# fields = ['tipo_autor', 'autor', 'primeiro_autor', 'data_relativa'] -# -# def clean(self): -# cd = super(AutoriaNormaForm, self).clean() -# -# if not self.is_valid(): -# return self.cleaned_data -# -# autorias = AutoriaNorma.objects.filter( -# norma=self.instance.norma, autor=cd['autor']) -# pk = self.instance.pk -# -# if ((not pk and autorias.exists()) or -# (pk and autorias.exclude(pk=pk).exists())): -# self.logger.error( -# "Autor ({}) já foi cadastrado.".format(cd['autor'])) -# raise ValidationError(_('Esse Autor já foi cadastrado.')) -# -# return cd \ No newline at end of file diff --git a/sapl/sdr/migrations/0005_auto_20200402_1313.py b/sapl/sdr/migrations/0005_auto_20200402_1313.py new file mode 100644 index 000000000..241a6b748 --- /dev/null +++ b/sapl/sdr/migrations/0005_auto_20200402_1313.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2020-04-02 16:13 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sdr', '0004_auto_20200331_1933'), + ] + + operations = [ + migrations.AlterModelOptions( + name='deliberacaoremota', + options={'ordering': ['-inicio'], 'verbose_name': 'Deliberação Remota', 'verbose_name_plural': 'Deliberações Remotas'}, + ), + migrations.AlterField( + model_name='deliberacaoremota', + name='inicio', + field=models.DateTimeField(blank=True, null=True, verbose_name='Data e Hora de Início'), + ), + ] diff --git a/sapl/sdr/models.py b/sapl/sdr/models.py index 571aef37e..2d6c4288e 100644 --- a/sapl/sdr/models.py +++ b/sapl/sdr/models.py @@ -21,7 +21,7 @@ class DeliberacaoRemota(models.Model): titulo = models.CharField(max_length=100, verbose_name=_('Título')) descricao = models.CharField(max_length=256, blank=True, verbose_name=_('Descrição')) - inicio = models.DateTimeField(auto_now=timezone.now, + inicio = models.DateTimeField(blank=True, null=True, verbose_name=_('Data e Hora de Início')) #TODO: obrigatorio? sessao_plenaria = models.ForeignKey(SessaoPlenaria, @@ -41,7 +41,7 @@ class DeliberacaoRemota(models.Model): class Meta: verbose_name = _('Deliberação Remota') verbose_name_plural = _('Deliberações Remotas') - ordering = ['chat_id', 'descricao'] + ordering = ['-inicio'] def __str__(self): return _('%(titulo)s') % {'titulo': self.titulo} diff --git a/sapl/sdr/views.py b/sapl/sdr/views.py index d218b4e95..f71304e91 100644 --- a/sapl/sdr/views.py +++ b/sapl/sdr/views.py @@ -5,6 +5,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.core.urlresolvers import reverse, reverse_lazy from django.views.generic import TemplateView +from django.utils import timezone from sapl.base.models import Autor from sapl.crud.base import Crud @@ -34,6 +35,7 @@ class DeliberacaoRemotaCrud(Crud): def get_initial(self): initial = super().get_initial() initial['created_by'] = self.request.user + initial['inicio'] = timezone.now() return initial class UpdateView(Crud.UpdateView): diff --git a/sapl/templates/sdr/deliberacaoremota_detail.html b/sapl/templates/sdr/deliberacaoremota_detail.html index 185cd738a..728cf8a4d 100644 --- a/sapl/templates/sdr/deliberacaoremota_detail.html +++ b/sapl/templates/sdr/deliberacaoremota_detail.html @@ -50,27 +50,27 @@ - {% if user.is_superuser %} - {% if deliberacao.created_by %} -
-
-
-
-

Criado por

- +
+
+
+
+

Criado por

+ - {% endif %} - {% endif %} +
+
+

- Link da sessão de vídeo + {% if not user.is_anonymous %} + {% if not deliberacao.finalizada %} + Link da sessão de vídeo + {% endif %} + {% endif %} {% endblock detail_content %} \ No newline at end of file