Browse Source

Cria o modulo app config

pull/585/head
Eduardo Calil 8 years ago
parent
commit
44d41b73c5
  1. 10
      sapl/base/forms.py
  2. 24
      sapl/base/migrations/0017_appconfig.py
  3. 33
      sapl/base/models.py
  4. 6
      sapl/base/urls.py
  5. 36
      sapl/base/views.py
  6. 4
      sapl/templates/base/layouts.yaml
  7. 1
      sapl/templates/sistema.html

10
sapl/base/forms.py

@ -15,7 +15,7 @@ from sapl.settings import MAX_IMAGE_UPLOAD_SIZE
from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label,
autor_modal)
from .models import CasaLegislativa
from .models import AppConfig, CasaLegislativa
class RangeWidgetOverride(forms.MultiWidget):
@ -284,3 +284,11 @@ class LoginForm(AuthenticationForm):
widget=forms.PasswordInput(
attrs={
'class': 'form-control', 'name': 'password'}))
class ConfiguracoesAppForm(ModelForm):
class Meta:
model = AppConfig
fields = ['documentos_administrativos',
'sequencia_numeracao',
'painel_aberto']

24
sapl/base/migrations/0017_appconfig.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-09-15 18:19
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0016_auto_20160701_0940'),
]
operations = [
migrations.CreateModel(
name='AppConfig',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('documentos_administrativos', models.CharField(blank=True, choices=[('O', 'Ostensivo'), ('R', 'Restritivo')], max_length=1, null=True, verbose_name='Ostensivo/Restritivo')),
('sequencia_numeracao', models.CharField(blank=True, choices=[('A', 'Sequencial por ano'), ('U', 'Sequencial único')], max_length=1, null=True, verbose_name='Sequência de numeração')),
('painel_aberto', models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], verbose_name='Painel aberto para usuário anônimo')),
],
),
]

33
sapl/base/models.py

@ -3,7 +3,14 @@ from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.translation import ugettext_lazy as _
from sapl.utils import UF
from sapl.utils import UF, YES_NO_CHOICES
TIPO_DOCUMENTO_ADMINISTRATIVO = (('O', _('Ostensivo')),
('R', _('Restritivo')))
SEQUENCIA_NUMERACAO = (('A', _('Sequencial por ano')),
('U', _('Sequencial único')))
def get_sessao_media_path(instance, subpath, filename):
@ -68,3 +75,27 @@ class ProblemaMigracao(models.Model):
class Meta:
verbose_name = _('Problema na Migração')
verbose_name_plural = _('Problemas na Migração')
class AppConfig(models.Model):
documentos_administrativos = models.CharField(
max_length=1,
verbose_name=_('Ostensivo/Restritivo'),
choices=TIPO_DOCUMENTO_ADMINISTRATIVO)
sequencia_numeracao = models.CharField(
max_length=1,
verbose_name=_('Sequência de numeração'),
choices=SEQUENCIA_NUMERACAO)
painel_aberto = models.BooleanField(
verbose_name=_('Painel aberto para usuário anônimo'),
choices=YES_NO_CHOICES)
class Meta:
verbose_name = _('Configurações da Aplicação')
verbose_name_plural = _('Configurações da Aplicação')
def __str__(self):
return _('Configurações da Aplicação - %(id)s') % {
'id': self.id}

6
sapl/base/urls.py

@ -4,7 +4,8 @@ from django.views.generic.base import TemplateView
from .apps import AppConfig
from .forms import LoginForm
from .views import (CasaLegislativaCrud, HelpView, RelatorioAtasView,
from .views import (AppConfigCrud,
CasaLegislativaCrud, HelpView, RelatorioAtasView,
RelatorioHistoricoTramitacaoView,
RelatorioMateriasPorAnoAutorTipoView,
RelatorioMateriasPorAutorView,
@ -22,7 +23,8 @@ urlpatterns = [
url(r'^ajuda/(?P<topic>\w+)$', HelpView.as_view(), name='help_topic'),
url(r'^ajuda/', TemplateView.as_view(template_name='ajuda/index.html'),
name='help_base'),
url(r'^casa_legislativa/', include(CasaLegislativaCrud.get_urls())),
url(r'^casa-legislativa/', include(CasaLegislativaCrud.get_urls())),
url(r'^app-config/', include(AppConfigCrud.get_urls())),
url(r'^login/$', views.login, {
'template_name': 'base/login.html', 'authentication_form': LoginForm},

36
sapl/base/views.py

@ -6,6 +6,7 @@ from django.db.models import Count, Q
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.views.generic.base import TemplateView
from django.views.generic.edit import BaseCreateView
from django_filters.views import FilterView
from sapl.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
@ -16,13 +17,14 @@ from sapl.sessao.models import (OrdemDia, PresencaOrdemDia, SessaoPlenaria,
SessaoPlenariaPresenca)
from sapl.utils import permissao_tb_aux
from .forms import (CasaLegislativaForm, RelatorioAtasFilterSet,
from .forms import (CasaLegislativaForm, ConfiguracoesAppForm,
RelatorioAtasFilterSet,
RelatorioHistoricoTramitacaoFilterSet,
RelatorioMateriasPorAnoAutorTipoFilterSet,
RelatorioMateriasPorAutorFilterSet,
RelatorioMateriasTramitacaoilterSet,
RelatorioPresencaSessaoFilterSet)
from .models import CasaLegislativa
from .models import AppConfig, CasaLegislativa
def get_casalegislativa():
@ -259,3 +261,33 @@ class SistemaView(PermissionRequiredMixin, TemplateView):
def has_permission(self):
return permissao_tb_aux(self)
class AppConfigCrud(Crud):
model = AppConfig
help_path = ''
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
list_field_names = ['documentos_administrativos',
'sequencia_numeracao',
'painel_aberto']
def has_permission(self):
return permissao_tb_aux(self)
class CreateView(PermissionRequiredMixin, CrudCreateView):
form_class = ConfiguracoesAppForm
def get(self, request, *args, **kwargs):
app_config = AppConfig.objects.last()
if app_config:
return HttpResponseRedirect(
reverse('sapl.base:appconfig_update',
kwargs={'pk': app_config.pk}))
else:
self.object = None
return super(BaseCreateView, self).get(
request, *args, **kwargs)
class UpdateView(PermissionRequiredMixin, CrudUpdateView):
form_class = ConfiguracoesAppForm

4
sapl/templates/base/layouts.yaml

@ -9,3 +9,7 @@ CasaLegislativa:
- endereco_web
- email
- informacao_geral
AppConfig:
{% trans 'Configurações da Aplicação' %}:
- documentos_administrativos sequencia_numeracao painel_aberto

1
sapl/templates/sistema.html

@ -6,6 +6,7 @@
<h2>Configuração Inicial</h2>
<div class="row">
<div class="col-md-6"><a href="{% url 'sapl.base:casalegislativa_list' %}" class="btn btn-link">Casa Legislativa</a></div>
<div class="col-md-6"><a href="{% url 'sapl.base:appconfig_list' %}" class="btn btn-link">Configurações da Aplicação</a></div>
</div>
<h2>Módulo Parlamentares</h2>

Loading…
Cancel
Save