Browse Source

FIX #1566

pull/1614/head
Mariana Mendes 8 years ago
parent
commit
a7e0ff8d82
  1. 34
      sapl/comissoes/forms.py
  2. 32
      sapl/comissoes/models.py

34
sapl/comissoes/forms.py

@ -158,42 +158,14 @@ class ReuniaoForm(ModelForm):
def clean(self):
super(ReuniaoForm, self).clean()
if not self.is_valid():
return self.cleaned_data
instance = self.instance
num = self.cleaned_data['numero']
com = self.cleaned_data['comissao']
tipo = self.cleaned_data['tipo']
periodo = self.cleaned_data['periodo']
error = ValidationError(
"Número de Reunião já existente "
"para a Comissão, Período e Tipo informados. "
"Favor escolher um número distinto.")
reunioes = Reuniao.objects.filter(numero=num,
comissao=com,
periodo=periodo,
tipo=tipo).\
values_list('id', flat=True)
qtd_reunioes = len(reunioes)
if qtd_reunioes > 0:
if instance.pk: # update
if instance.pk not in reunioes or qtd_reunioes > 1:
raise error
else: # create
raise error
if self.cleaned_data['hora_fim']:
if (self.cleaned_data['hora_fim'] <
self.cleaned_data['hora_inicio']):
msg = _('A hora de término não pode ser menor que a de início')
msg = _('A hora de término da reunião não pode ser menor que a de início')
raise ValidationError(msg)
return self.cleaned_data

32
sapl/comissoes/models.py

@ -1,4 +1,3 @@
import reversion
from django.db import models
from django.utils.translation import ugettext_lazy as _
@ -53,22 +52,18 @@ class Comissao(models.Model):
secretario = models.CharField(
max_length=30, blank=True, verbose_name=_('Secretário'))
telefone_reuniao = models.CharField(
max_length=15,
blank=True,
max_length=15, blank=True,
verbose_name=_('Tel. Sala Reunião'))
endereco_secretaria = models.CharField(
max_length=100,
blank=True,
max_length=100, blank=True,
verbose_name=_('Endereço Secretaria'))
telefone_secretaria = models.CharField(
max_length=15,
blank=True,
max_length=15, blank=True,
verbose_name=_('Tel. Secretaria'))
fax_secretaria = models.CharField(
max_length=15, blank=True, verbose_name=_('Fax Secretaria'))
agenda_reuniao = models.CharField(
max_length=100,
blank=True,
max_length=100, blank=True,
verbose_name=_('Data/Hora Reunião'))
local_reuniao = models.CharField(
max_length=100, blank=True, verbose_name=_('Local Reunião'))
@ -84,7 +79,6 @@ class Comissao(models.Model):
default=False,
choices=YES_NO_CHOICES,
verbose_name=_('Comissão Ativa?'))
autor = SaplGenericRelation(Autor,
related_query_name='comissao_set',
fields_search=(
@ -171,8 +165,7 @@ class Participacao(models.Model): # ComposicaoComissao
null=True,
verbose_name=_('Data Desligamento'))
motivo_desligamento = models.CharField(
max_length=150,
blank=True,
max_length=150, blank=True,
verbose_name=_('Motivo Desligamento'))
observacao = models.CharField(
max_length=150, blank=True, verbose_name=_('Observação'))
@ -190,8 +183,7 @@ def get_comissao_media_path(instance, subpath, filename):
def pauta_upload_path(instance, filename):
return texto_upload_path(
instance, filename, subpath='pauta', pk_first=True)
return texto_upload_path(instance, filename, subpath='pauta', pk_first=True)
def ata_upload_path(instance, filename):
@ -199,8 +191,7 @@ def ata_upload_path(instance, filename):
def anexo_upload_path(instance, filename):
return texto_upload_path(
instance, filename, subpath='anexo', pk_first=True)
return texto_upload_path(instance, filename, subpath='anexo', pk_first=True)
class Reuniao(models.Model):
@ -237,20 +228,17 @@ class Reuniao(models.Model):
max_length=150, blank=True,
verbose_name=_('URL Arquivo Vídeo (Formatos MP4 / FLV / WebM)'))
upload_pauta = models.FileField(
blank=True,
null=True,
blank=True, null=True,
upload_to=pauta_upload_path,
verbose_name=_('Pauta da Reunião'),
validators=[restringe_tipos_de_arquivo_txt])
upload_ata = models.FileField(
blank=True,
null=True,
blank=True, null=True,
upload_to=ata_upload_path,
verbose_name=_('Ata da Reunião'),
validators=[restringe_tipos_de_arquivo_txt])
upload_anexo = models.FileField(
blank=True,
null=True,
blank=True, null=True,
upload_to=anexo_upload_path,
verbose_name=_('Anexo da Reunião'))

Loading…
Cancel
Save