Skip to content

Commit

Permalink
feat: add exibição da chefia do departamento
Browse files Browse the repository at this point in the history
  • Loading branch information
tacianosilva committed Apr 3, 2024
1 parent aaf9d5e commit 0a9004c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/dao/departamento_dao.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from core.models import Centro, Departamento
from datetime import datetime

import pytz

from core.models import Centro, Departamento, FuncaoGratificada


def get_departamentos():
Expand Down
12 changes: 12 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
Expand Down Expand Up @@ -33,6 +34,17 @@ class Departamento(models.Model):
def __str__(self):
return self.nome + ' - ' + self.sigla + '/' + self.centro.sigla

def get_chefe(self):
atividade = 'CHEFE DE DEPARTAMENTO'
agora = datetime.now()
chefes = FuncaoGratificada.objects.filter(
lotacao=self.nome,
atividade=atividade,
fim__gt=agora
)

return chefes


class Docente(models.Model):
siape = models.IntegerField(unique=True)
Expand Down
6 changes: 6 additions & 0 deletions core/templates/core/departamento/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h3 class="page-section-heading text-center text-secondary mb-0">Departamentos</
<th>Código</th>
<th>Sigla</th>
<th>Nome</th>
<th>Chefia</th>
<th>Centro</th>
</tr>
{% for depto in departamentos %}
Expand All @@ -21,6 +22,11 @@ <h3 class="page-section-heading text-center text-secondary mb-0">Departamentos</
<td align="center">{{ depto.codigo }}</td>
<td align="center">{{ depto.sigla }}</td>
<td align="center">{{ depto.nome }}</td>
<td align="center">
{% for chefe in depto.get_chefe %}
{{ chefe.nome }}<br>
{% endfor %}
</td>
<td align="center">{{ depto.centro.nome }}</td>
</tr>
{% endfor %}
Expand Down

0 comments on commit 0a9004c

Please sign in to comment.