Browse Source

Usar membro da equipe na linha de assinatura da declaração de visita

pull/159/head
Sesostris Vieira 3 years ago
parent
commit
26a3bc02be
  1. 18
      sigi/apps/eventos/migrations/0021_equipe_assina_oficio.py
  2. 3
      sigi/apps/eventos/models.py
  3. 4
      sigi/apps/eventos/templates/admin/eventos/evento/change_form.html
  4. 5
      sigi/apps/eventos/templates/eventos/declaracao_pdf.html
  5. 117
      sigi/apps/eventos/views.py
  6. 6
      sigi/apps/servidores/admin.py
  7. 18
      sigi/apps/servidores/migrations/0009_servidor_cargo.py
  8. 1
      sigi/apps/servidores/models.py

18
sigi/apps/eventos/migrations/0021_equipe_assina_oficio.py

@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-06 12:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('eventos', '0020_anexo_convite'),
]
operations = [
migrations.AddField(
model_name='equipe',
name='assina_oficio',
field=models.BooleanField(default=False, verbose_name='Assina ofício de comparecimento'),
),
]

3
sigi/apps/eventos/models.py

@ -166,6 +166,9 @@ class Equipe(models.Model):
funcao = models.ForeignKey(
Funcao, on_delete=models.PROTECT, verbose_name=_("Função na equipe")
)
assina_oficio = models.BooleanField(
_("Assina ofício de comparecimento"), default=False
)
observacoes = models.TextField(_("Observações"), blank=True)
class Meta:

4
sigi/apps/eventos/templates/admin/eventos/evento/change_form.html

@ -2,11 +2,11 @@
{% load i18n %}
{% block object-tools-items %}
<div class="collection-item">
<li>
<a href="{% url 'evento-declaracao' object_id %}">
<i class="left material-icons" aria-hidden="true">picture_as_pdf</i>
{% trans "Declaração" %}
</a>
</div>
</li>
{{ block.super }}
{% endblock %}

5
sigi/apps/eventos/templates/eventos/declaracao_pdf.html

@ -1,6 +1,11 @@
{% extends 'pdf/base_report.html' %}
{% load i18n %}
{% block page-footer-settings %}
{{ block.super }}
@bottom-right { content: ""; }
{% endblock %}
{% block page_size %}{{ pagesize }}{% endblock page_size %}
{% block page_margin %}4cm {{ pagemargin }}cm {{ pagemargin }}cm 2cm{% endblock page_margin %}

117
sigi/apps/eventos/views.py

@ -58,6 +58,65 @@ def calendario(request):
return render(request, "eventos/calendario.html", context)
@login_required
def declaracao(request, id):
if request.method == "POST":
form = SelecionaModeloForm(request.POST)
if form.is_valid():
evento = get_object_or_404(Evento, id=id)
modelo = form.cleaned_data["modelo"]
membro = (
evento.equipe_set.filter(assina_oficio=True).first()
or evento.equipe_set.first()
)
if membro:
servidor = membro.membro
else:
servidor = None
template_string = (
"""
{% extends "eventos/declaracao_pdf.html" %}
{% block text_body %}"""
+ modelo.texto
+ """
{% endblock %}
"""
)
context = Context(
{
"pagesize": modelo.formato,
"pagemargin": modelo.margem,
"evento": evento,
"servidor": servidor,
"data": datetime.date.today(),
}
)
string = Template(template_string).render(context)
# return HttpResponse(string)
response = HttpResponse(
headers={
"Content-Type": "application/pdf",
"Content-Disposition": 'attachment; filename="declaração.pdf"',
}
)
pdf = HTML(
string=string,
url_fetcher=django_url_fetcher,
encoding="utf-8",
base_url=request.build_absolute_uri("/"),
)
pdf.write_pdf(target=response)
return response
else:
form = SelecionaModeloForm()
context = site.each_context(request)
context["form"] = form
context["evento_id"] = id
return render(request, "eventos/seleciona_modelo.html", context)
def evento(request, id):
context = site.each_context(request)
evento = get_object_or_404(Evento, id=id)
@ -167,6 +226,13 @@ def convida_casa(request, evento_id, casa_id):
query_str += f"anexo_id={oficio.id}&"
if projeto.modelo_minuta:
doc = Document(projeto.modelo_minuta.path)
if casa.tipo.sigla == "CM":
ente = (
f"Município de {casa.municipio.nome}, "
f"{casa.municipio.uf.sigla}"
)
else:
ente = f"Estado de {casa.municipio.uf.nome}"
doc_context = Context(
{
"evento": evento,
@ -174,6 +240,7 @@ def convida_casa(request, evento_id, casa_id):
"presidente": presidente,
"contato": contato,
"data": datetime.date.today(),
"ente": ente,
"doravante": casa.tipo.nome.split(" ")[0],
}
)
@ -621,53 +688,3 @@ def gerar_anexo(casa, presidente, contato, path, modelo, nome, texto):
# writer.writerow(reg)
# return response
@login_required
def declaracao(request, id):
if request.method == "POST":
form = SelecionaModeloForm(request.POST)
if form.is_valid():
evento = get_object_or_404(Evento, id=id)
modelo = form.cleaned_data["modelo"]
template_string = (
"""
{% extends "eventos/declaracao_pdf.html" %}
{% block text_body %}"""
+ modelo.texto
+ """
{% endblock %}
"""
)
context = Context(
{
"pagesize": modelo.formato,
"pagemargin": modelo.margem,
"evento": evento,
"data": datetime.date.today(),
}
)
string = Template(template_string).render(context)
# return HttpResponse(string)
response = HttpResponse(
headers={
"Content-Type": "application/pdf",
"Content-Disposition": 'attachment; filename="declaração.pdf"',
}
)
pdf = HTML(
string=string,
url_fetcher=django_url_fetcher,
encoding="utf-8",
base_url=request.build_absolute_uri("/"),
)
pdf.write_pdf(target=response)
return response
else:
form = SelecionaModeloForm()
context = site.each_context(request)
context["form"] = form
context["evento_id"] = id
return render(request, "eventos/seleciona_modelo.html", context)

6
sigi/apps/servidores/admin.py

@ -84,8 +84,10 @@ class ServidorAdmin(admin.ModelAdmin):
list_display = (
"imagem_foto",
"nome_completo",
"apelido",
"is_active",
"servico",
"cargo",
)
list_display_links = (
"imagem_foto",
@ -98,6 +100,8 @@ class ServidorAdmin(admin.ModelAdmin):
)
search_fields = (
"nome_completo",
"apelido",
"cargo",
"user__email",
"user__first_name",
"user__last_name",
@ -113,8 +117,10 @@ class ServidorAdmin(admin.ModelAdmin):
"fields": (
"user",
"nome_completo",
"apelido",
"foto",
"servico",
"cargo",
)
},
),

18
sigi/apps/servidores/migrations/0009_servidor_cargo.py

@ -0,0 +1,18 @@
# Generated by Django 4.0.4 on 2022-05-06 12:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('servidores', '0008_alter_servico_id_alter_servidor_foto_and_more'),
]
operations = [
migrations.AddField(
model_name='servidor',
name='cargo',
field=models.CharField(blank=True, max_length=100),
),
]

1
sigi/apps/servidores/models.py

@ -51,6 +51,7 @@ class Servidor(models.Model):
servico = models.ForeignKey(
Servico, on_delete=models.SET_NULL, blank=True, null=True
)
cargo = models.CharField(max_length=100, blank=True)
externo = models.BooleanField(_("colaborador externo"), default=False)
orgao_origem = models.CharField(
_("órgão de origem, "), max_length=100, blank=True

Loading…
Cancel
Save