Browse Source

App serviços com exportação

revisaoSidenav
Sesostris Vieira 3 years ago
parent
commit
dcebe1ca95
  1. 30
      sigi/apps/servicos/admin.py
  2. 23
      sigi/apps/servicos/templates/admin/servicos/casaatendida/change_list.html
  3. 33
      sigi/apps/servicos/templates/servico/change_list.html

30
sigi/apps/servicos/admin.py

@ -1,4 +1,5 @@
from datetime import date, timedelta
import resource
from django.contrib import admin
from django.urls import reverse
from django.utils.encoding import force_str
@ -6,11 +7,33 @@ from django.utils.safestring import mark_safe
from django.forms.models import ModelForm
from django.http import Http404, HttpResponseRedirect
from django.utils.translation import gettext as _
from import_export.fields import Field
from sigi.apps.casas.admin import FuncionariosInline, GerentesInterlegisFilter
from sigi.apps.casas.models import Orgao
from sigi.apps.servicos.models import (Servico, LogServico, CasaAtendida,
TipoServico)
from sigi.apps.utils.mixins import CartExportMixin, LabeledResourse
class ServicoExportResourse(LabeledResourse):
telefone_casa = Field(column_name='Casa Legislativa/telefone')
hospedagem_interlegis = Field(column_name='hospedagem no interlegis')
class Meta:
model = Servico
fields = ('casa_legislativa__nome', 'casa_legislativa__municipio__nome',
'casa_legislativa__municipio__uf__sigla',
'casa_legislativa__email', 'telefone_casa',
'contato_tecnico__nome', 'contato_tecnico__email',
'contato_tecnico__nota', 'tipo_servico__nome', 'url',
'hospedagem_interlegis', 'data_ativacao', 'data_desativacao',
'motivo_desativacao', 'data_ultimo_uso', 'erro_atualizacao')
export_order = fields
def dehydrate_telefone_casa(self, servico):
return servico.casa_legislativa.telefone
def dehydrate_hospedagem_interlegis(self, servico):
if servico.hospedagem_interlegis:
return _("Sim")
else:
return _("Não")
class LogServicoInline(admin.StackedInline):
@ -110,8 +133,7 @@ class ServicoAtivoFilter(admin.SimpleListFilter):
return queryset
@admin.register(Servico)
class ServicoAdmin(admin.ModelAdmin):
change_list_template = "servico/change_list.html"
class ServicoAdmin(CartExportMixin, admin.ModelAdmin):
form = ServicoFormAdmin
actions = ['calcular_data_uso', ]
list_display = ('casa_legislativa', 'get_codigo_interlegis', 'get_uf',
@ -142,11 +164,11 @@ class ServicoAdmin(admin.ModelAdmin):
'casa_legislativa__municipio__uf',
)
list_display_links = []
actions = ['adicionar_servicos']
ordering = ('casa_legislativa__municipio__uf', 'casa_legislativa',
'tipo_servico',)
inlines = (LogServicoInline,)
search_fields = ('casa_legislativa__search_text',)
resource_class = ServicoExportResourse
def get_codigo_interlegis(self, obj):
return obj.casa_legislativa.codigo_interlegis

23
sigi/apps/servicos/templates/admin/servicos/casaatendida/change_list.html

@ -1,23 +0,0 @@
{% extends "admin/change_list.html" %}
{% load admin_list i18n admin_urls %}
{% block extrahead %}
{{ block.super }}
<script type="text/javascript">
function dismissRelatedLookupPopup(win, chosenId) {
win.close();
url = "{% url 'admin:servicos_casaatendida_changelist' %}" + chosenId;
// alert(url);
document.location.href = url;
}
</script>
{% endblock %}
{% block object-tools-items %}
<li><a id="lookup_id_casa_legislativa" onclick="return showRelatedObjectLookupPopup(this);"
href="{% url 'admin:casas_orgao_changelist' %}?codigo_interlegis__exact=" class="addlink">
<span class="glyphicon glyphicon-plus"></span>
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
</a></li>
{{ block.super }}
{% endblock %}

33
sigi/apps/servicos/templates/servico/change_list.html

@ -1,33 +0,0 @@
{% extends "change_list_with_cart.html" %}
{% load i18n %}
{% block extra_search %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Filtro de datas</a>
<p class="navbar-text">Use AAAA, AAAA-MM ou AAAA-MM-DD</p>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form class="navbar-form navbar-left" role="extra-search" id="changelist-extrasearch" action="" method="get">
<div class="form-group">
<label for="data_ativacao__gte">{% trans 'Ativados a partir de' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_ativacao__gte" value="" id="data_ativacao__gte">
<label for="data_ativacao__lte">{% trans 'até' %}:</label>
<input type="text" class="form-control search-query" size="10" name="data_ativacao__lte" value="" id="data_ativacao__lte">
</div>
<button type="submit" class="btn btn-default navbar-btn ">
<span class="glyphicon glyphicon-search"></span>
</button>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
{% endblock %}
Loading…
Cancel
Save