Browse Source

Declaração de participação nos eventos

pull/159/head
Sesostris Vieira 3 years ago
parent
commit
9ab04ec203
  1. 9
      sigi/apps/eventos/admin.py
  2. 20
      sigi/apps/eventos/templates/eventos/declaracao_pdf.html
  3. 49
      sigi/apps/eventos/templates/eventos/seleciona_modelo.html
  4. 2
      sigi/apps/eventos/urls.py
  5. 77
      sigi/apps/eventos/views.py
  6. 5
      sigi/templates/pdf/base.html

9
sigi/apps/eventos/admin.py

@ -21,18 +21,17 @@ class ModeloDeclaracaoAdmin(admin.ModelAdmin):
list_display = ('nome', 'formato') list_display = ('nome', 'formato')
formfield_overrides = {HTMLField: {'widget': AdminTinyMCE}} formfield_overrides = {HTMLField: {'widget': AdminTinyMCE}}
class EquipeInline(admin.StackedInline):
class EquipeInline(admin.TabularInline):
model = Equipe model = Equipe
class ConviteInline(admin.TabularInline): class ConviteInline(admin.StackedInline):
model = Convite model = Convite
raw_id_fields = ('casa',) raw_id_fields = ('casa',)
class ModuloInline(admin.TabularInline): class ModuloInline(admin.StackedInline):
model = Modulo model = Modulo
class AnexoInline(admin.TabularInline): class AnexoInline(admin.StackedInline):
model = Anexo model = Anexo
exclude = ('data_pub',) exclude = ('data_pub',)

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

@ -1,24 +1,18 @@
{% extends 'base_report.html' %} {% extends 'pdf/base_report.html' %}
{% load i18n %} {% load i18n %}
{% block pagesize %}{{ pagesize }}{% endblock pagesize %} {% block page_size %}{{ pagesize }}{% endblock page_size %}
{% block pagemargin %}4cm {{ pagemargin }}cm {{ pagemargin }}cm 2cm{% endblock pagemargin %} {% block page_margin %}4cm {{ pagemargin }}cm {{ pagemargin }}cm 2cm{% endblock page_margin %}
{% block report %} {% block main_content %}
{% for convite in evento.convite_set.all %} {% for convite in evento.convite_set.all %}
{% with convite.casa as casa %} {% with convite.casa as casa %}
{% for nome in convite.nomes_participantes.splitlines %} {% for nome in convite.nomes_participantes.splitlines %}
{% block text_body %}{% endblock %} {% block text_body %}{% endblock %}
<pdf:nextpage /> {% if not forloop.last %}
<div class="new-page"/>
{% endif %}
{% endfor %} {% endfor %}
{% endwith %} {% endwith %}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
{%block page_foot%}
<table>
<tr>
<td class="footer-left">{% trans 'Emissão:' %} {% now "d/m/Y H:i:s" %}</td>
</tr>
</table>
{% endblock %}

49
sigi/apps/eventos/templates/eventos/seleciona_modelo.html

@ -1,25 +1,48 @@
{% extends "admin/base_site.html" %} {% extends "admin/base_site.html" %}
{% load i18n bootstrap3 %} {% load i18n static %}
{% block content_title %} {% block extrastyle %}
<h1 class="pull-left">{% trans 'Emitir declaração de comparecimento' %}</h1> {{ block.super }}
<link rel="stylesheet" href="{% static 'material/admin/css/submit_line.min.css' %}">
{% endblock %} {% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block messages %}
{% if error %}
<ul class="messagelist">
<li class="error">{{ error|capfirst }}</li>
</ul>
{% endif %}
{% endblock messages %}
{% block content %} {% block content %}
{% if error %} <div class="container">
<div class="alert alert-danger" role="alert"> <div class="card">
{{ error }} <div class="card-content">
</div> <span class="card-title">{% trans 'Emitir declaração de comparecimento' %}</span>
{% endif %} <form id="select-form" name="select-form" action="" method="post" novalidate>
<div id="content-main">
<form action="" method="post">{% csrf_token %}
{% csrf_token %} {% csrf_token %}
<div class="form-group"> <div class="form-group">
{% bootstrap_form form %} {{ form }}
</div> </div>
<input type="submit" value="Imprimir" class="btn btn-primary"/>
<a class="btn btn-danger" role="button" href="{% url 'admin:eventos_evento_change' evento_id %}">{% trans "Voltar" %}</a>
</form> </form>
</div>
<div class="card-action">
<div class="submit-row">
<div class="open-actions">
<button class="default waves-effect waves-light btn" type="submit" form="select-form" name="submit" value="print">
<i class="material-icons">picture_as_pdf</i>
{% trans "Imprimir" %}
</button>
<a class="default waves-effect waves-light btn" role="button" href="{% url 'admin:eventos_evento_change' evento_id %}">
<i class="material-icons">undo</i>
{% trans "Voltar" %}
</a>
</div>
</div>
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

2
sigi/apps/eventos/urls.py

@ -3,6 +3,8 @@ from sigi.apps.eventos import views
urlpatterns = [ urlpatterns = [
path('calendario/', views.calendario, name='eventos-calendario'), path('calendario/', views.calendario, name='eventos-calendario'),
path('evento/<int:id>/declaracao/', views.declaracao,
name='evento-declaracao'),
] ]
# from django.conf.urls import patterns, url # from django.conf.urls import patterns, url

77
sigi/apps/eventos/views.py

@ -1,9 +1,14 @@
import calendar import calendar
import datetime import datetime
import locale import locale
from django.contrib.admin.sites import site
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.shortcuts import render from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from django.template import Template, Context
from django.utils.translation import to_locale, get_language, gettext as _ from django.utils.translation import to_locale, get_language, gettext as _
from django_weasyprint.utils import django_url_fetcher
from weasyprint import HTML
from sigi.apps.eventos.models import Evento, Equipe, Convite, Modulo from sigi.apps.eventos.models import Evento, Equipe, Convite, Modulo
from sigi.apps.eventos.forms import SelecionaModeloForm from sigi.apps.eventos.forms import SelecionaModeloForm
from sigi.apps.servidores.models import Servidor from sigi.apps.servidores.models import Servidor
@ -400,36 +405,42 @@ def calendario(request):
# return response # return response
# @login_required @login_required
# def declaracao(request, id): def declaracao(request, id):
# if request.method == 'POST': if request.method == 'POST':
# form = SelecionaModeloForm(request.POST) form = SelecionaModeloForm(request.POST)
# if form.is_valid(): if form.is_valid():
# evento = get_object_or_404(Evento, id=id) evento = get_object_or_404(Evento, id=id)
# modelo = form.cleaned_data['modelo'] modelo = form.cleaned_data['modelo']
# template_string = ( template_string = (
# """ """
# {% extends "eventos/declaracao_pdf.html" %} {% extends "eventos/declaracao_pdf.html" %}
# {% block text_body %}""" + {% block text_body %}""" +
# modelo.texto + """ modelo.texto + """
# {% endblock %} {% endblock %}
# """ """
# ) )
# context = Context( context = Context({
# {'pagesize': modelo.formato, 'pagesize': modelo.formato,
# 'pagemargin': modelo.margem, 'pagemargin': modelo.margem,
# 'evento': evento, 'evento': evento,
# 'data': datetime.date.today(), 'data': datetime.date.today(),
# } })
# ) string = Template(template_string).render(context)
# template = Template(template_string) # return HttpResponse(string)
# # return HttpResponse(template.render(context)) response = HttpResponse(headers={
# return pdf_renderer(template, context, 'declaracao.pdf') 'Content-Type': "application/pdf",
# else: 'Content-Disposition': 'attachment; filename="declaração.pdf"'
# form = SelecionaModeloForm() })
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()
# return render( context = site.each_context(request)
# request, context['form'] = form
# 'eventos/seleciona_modelo.html', context['evento_id'] = id
# {'form': form, 'evento_id': id}
# ) return render(request, 'eventos/seleciona_modelo.html', context)

5
sigi/templates/pdf/base.html

@ -28,12 +28,13 @@
header {position: running(header);} header {position: running(header);}
footer {position: running(footer);} footer {position: running(footer);}
} }
@media print {
}
body { body {
font-family: Helvetica, Arial, sans-serif; font-family: Helvetica, Arial, sans-serif;
font-size: 10px; font-size: 10px;
} }
div.new-page {
break-before: always;
}
{% block extra_style %}{% endblock extra_style %} {% block extra_style %}{% endblock extra_style %}
</style> </style>
{% block extra_head %}{% endblock extra_head %} {% block extra_head %}{% endblock extra_head %}

Loading…
Cancel
Save