Browse Source

Add edit/remove DocumentoAdministrativo

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
293bb82722
  1. 5
      protocoloadm/urls.py
  2. 84
      protocoloadm/views.py
  3. 93
      templates/protocoloadm/detail_doc_adm.html
  4. 8
      templates/protocoloadm/detail_doc_detail.html
  5. 14
      templates/protocoloadm/pesquisa_doc_adm.html
  6. 0
      templates/protocoloadm/pesquisa_documento_detail.html

5
protocoloadm/urls.py

@ -1,6 +1,6 @@
from django.conf.urls import include, url
from protocoloadm.views import (AnularProtocoloAdmView,
DetailDocumentoAdministrativo,
PesquisarDocumentoAdministrativo,
ProposicaoReceberView,
ProposicoesIncorporadasView,
@ -44,7 +44,8 @@ urlpatterns = [
ProtocoloMateriaView.as_view(), name='protocolar_mat'),
url(r'^protocoloadm/pesq-doc-adm',
PesquisarDocumentoAdministrativo.as_view(), name='pesq_doc_adm'),
url(r'^protocoloadm/doc-adm/(?P<pk>\d+)',
DetailDocumentoAdministrativo.as_view(), name='detail_doc_adm'),
# TODO: move to Proposicoes app
url(r'^protocoloadm/proposicao-receber',

84
protocoloadm/views.py

@ -3,13 +3,14 @@ from re import sub
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.db.models import Max
from django.shortcuts import render
from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView
from django.views.generic import ListView, DetailView
from django.views.generic.base import TemplateView
from django.views.generic.edit import FormMixin
from vanilla import GenericView
@ -546,10 +547,15 @@ class PesquisarDocumentoAdministrativo(TemplateView):
def get_tipos_doc(self):
return TipoDocumentoAdministrativo.objects.all()
def get(self, request, *args, **kwargs):
return self.render_to_response(
{"tipos_doc": TipoDocumentoAdministrativo.objects.all()}
)
def post(self, request, *args, **kwargs):
if request.POST['tipo_documento']:
kwargs['tipo_documento'] = request.POST['tipo_documento']
kwargs['tipo_id'] = request.POST['tipo_documento']
if request.POST['numero']:
kwargs['numero'] = request.POST['numero']
@ -580,6 +586,7 @@ class PesquisarDocumentoAdministrativo(TemplateView):
else:
kwargs['tramitacao'] = request.POST['tramitacao']
# TODO
# if request.POST['localizacao']:
# kwargs['localizacao'] = request.POST['localizacao']
@ -588,6 +595,73 @@ class PesquisarDocumentoAdministrativo(TemplateView):
doc = DocumentoAdministrativo.objects.filter(**kwargs)
return self.render_to_response(
{'documentos': doc}
)
if len(doc) == 0:
return self.render_to_response(
{'error': 'Nenhum resultado encontrado!',
"tipos_doc": TipoDocumentoAdministrativo.objects.all()}
)
else:
return self.render_to_response(
{'documentos': doc}
)
class DetailDocumentoAdministrativo(DetailView):
template_name = "protocoloadm/detail_doc_adm.html"
def get_tipos_doc(self):
return TipoDocumentoAdministrativo.objects.all()
def get(self, request, *args, **kwargs):
doc = DocumentoAdministrativo.objects.get(id=kwargs['pk'])
return self.render_to_response({
'doc': doc,
'tipos_doc': TipoDocumentoAdministrativo.objects.all()
})
def post(self, request, *args, **kwargs):
if 'Salvar' in request.POST:
documento = DocumentoAdministrativo.objects.get(id=kwargs['pk'])
if request.POST['numero']:
documento.numero = request.POST['numero']
if request.POST['ano']:
documento.ano = request.POST['ano']
if request.POST['data']:
documento.data = datetime.strptime(
request.POST['data'], "%d/%m/%Y")
if request.POST['numero_protocolo']:
documento.numero_protocolo = request.POST['numero_protocolo']
if request.POST['assunto']:
documento.assunto = request.POST['assunto']
if request.POST['interessado']:
documento.interessado = request.POST['interessado']
if request.POST['tramitacao']:
documento.tramitacao = request.POST['tramitacao']
if request.POST['dias_prazo']:
documento.dias_prazo = request.POST['dias_prazo']
if request.POST['data_fim_prazo']:
documento.data_fim_prazo = datetime.strptime(
request.POST['data_fim_prazo'], "%d/%m/%Y")
if request.POST['observacao']:
documento.observacao = request.POST['observacao']
documento.save()
elif 'Excluir' in request.POST:
DocumentoAdministrativo.objects.get(
id=kwargs['pk']).delete()
return HttpResponseRedirect(self.get_success_url())
def get_success_url(self):
return reverse('pesq_doc_adm')

93
templates/protocoloadm/detail_doc_adm.html

@ -0,0 +1,93 @@
{% extends "protocoloadm/detail_doc_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block detail_content %}
<fieldset>
<legend>Formulário de Cadastro</legend>
<form method="POST">
{% csrf_token %}
<fieldset>
<legend>Identificação Básica</legend>
<ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3">
<li><b>Tipo Documento</b></li>
<li><b>Número</b></li>
<li><b>Ano</b></li>
</ul>
<ul class="small-block-grid-3 medium-block-grid-3 large-block-grid-3">
<li>
<select name="tipo_documento" disabled>
{% for tipo in tipos_doc %}
{% if doc.tipo.id == tipo.id %}
<option value="{{ tipo }}" selected> {{ tipo.sigla }} - {{ tipo.descricao }} </option>
{% endif %}
{% endfor %}
</select>
</li>
<li><input type="text" name="numero" value="{{ doc.numero }}"/></li>
<li><input type="text" name="ano" value="{{ doc.ano }}"/></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li><b>Data</b></li>
<li><b>Núm. Protocolo</b></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li><input type="text" name="data" class="dateinput" value="{{ doc.data|date:"d/m/Y" }}"/></li>
<li><input type="text" name="numero_protocolo" value="{{ doc.numero_protocolo }}"/></li>
</ul>
<ul class="small-block-grid-1 medium-block-grid-1 large-block-grid-1">
<li><b>Assunto</b></li>
</ul>
<ul class="small-block-grid-1 medium-block-grid-1 large-block-grid-1">
<li><textarea rows="4" cols="50" name="assunto">{{ d.assunto }}</textarea></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li><b>Interessado</b></li>
<li><b>Em Tramitação?</b></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li><input type="text" name="interessado" value="{{ doc.interessado }}"/></li>
<li>
<select name="tramitacao">
<option value="True" {% if doc.tramitacao == True %} selected {% endif %} > Sim </option>
<option value="False" {% if doc.tramitacao == False %} selected {% endif %}> Não </option>
</select>
</li>
</ul>
</fieldset>
<fieldset>
<legend>Outras Informações</legend>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li><b>Dias Prazo</b></li>
<li><b>Data Fim Prazo</b></li>
</ul>
<ul class="small-block-grid-2 medium-block-grid-2 large-block-grid-2">
<li><input type="text" name="dias_prazo" {% if doc.diasprazo != None %} value="{{ doc.dias_prazo }}" {% endif %} /></li>
<li><input type="text" name="data_fim_prazo" class="dateinput" {% if doc.data_fim_prazo != None %} value="{{ doc.data_fim_prazo }}" {% endif %} /></li>
</ul>
<ul class="small-block-grid-1 medium-block-grid-1 large-block-grid-1">
<li><b>Obervação</b></li>
</ul>
<ul class="small-block-grid-1 medium-block-grid-1 large-block-grid-1">
<li><textarea rows="4" cols="50" name="observacao">{{ documento.observacao }}</textarea></li>
</ul>
</fieldset>
<input type="submit" value="Salvar" name="Salvar" class="primary button"/>
<input type="submit" value="Excluir" name="Excluir" class="primary button"/>
</form>
</fieldset>
{% endblock %}
{% block foot_js %}
<script type="text/javascript">
$(function () {
$('.dateinput').fdatepicker({
// TODO localize
format: 'dd/mm/yyyy',
language: 'pt',
endDate: '31/12/2100',
todayBtn: true
});
});
</script>
{% endblock %}

8
templates/protocoloadm/detail_doc_detail.html

@ -0,0 +1,8 @@
{% extends "crud/detail.html" %}
{% load i18n %}
{% block sections_nav %}
<dl class="sub-nav left">
<dd><a href="#" class="button secondary">{% trans 'Documento Acessório' %}</a></dd>
<dd><a href="#" class="button secondary">{% trans 'Tramitação' %}</a></dd>
{% endblock sections_nav %}

14
templates/protocoloadm/pesquisa_doc_adm.html

@ -1,4 +1,4 @@
{% extends "protocoloadm/documento_detail.html" %}
{% extends "protocoloadm/pesquisa_documento_detail.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
@ -12,7 +12,7 @@
{% for d in documentos %}
<tr>
<td>
<a href="#"><b>{{ d.tipo.sigla }} {{ d.numero }}/{{ d.ano }} - {{ d.tipo }}</b></a> <br />
<a href="{% url 'detail_doc_adm' d.id %}"><b>{{ d.tipo.sigla }} {{ d.numero }}/{{ d.ano }} - {{ d.tipo }}</b></a> <br />
{{ d.assunto }} <br />
<b>Interessado:</b> {{ d.interessado }}
</td>
@ -23,10 +23,14 @@
<form method="POST">
{% csrf_token %}
{% if error %}
<h5 align="center"><font color="#FF0000">{{ error }}</font></h5>
{% endif %}
Tipo Documento:
<select name="tipo_documento">
<option value=""> --- </option>
{% for tipo in view.get_tipos_doc %}
{% for tipo in tipos_doc %}
<option value="{{tipo.id}}">{{tipo.descricao}}</option>
{% endfor %}
</select> <br>
@ -47,11 +51,11 @@
<!-- TODO
Localização Atual:
<select name="localizacao">
<option value=""> --- </option>
<option value=""> - </option>
</select> <br>
Situação:
<select name="situacao">
<option value=""> --- </option>
<option value=""> - </option>
</select> <br><br>
-->

0
templates/protocoloadm/documento_detail.html → templates/protocoloadm/pesquisa_documento_detail.html

Loading…
Cancel
Save