Browse Source

Conc refatoração no Cada de Autor e Tipos de Autor

pull/752/head
LeandroRoberto 8 years ago
parent
commit
2a44eb455a
  1. 2
      sapl/api/urls.py
  2. 3
      sapl/api/views.py
  3. 12
      sapl/base/forms.py
  4. 3
      sapl/crud/base.py
  5. 2
      sapl/materia/forms.py
  6. 1
      sapl/materia/views.py
  7. 2
      sapl/templates/base.html
  8. 7
      sapl/templates/base/autor_form.html
  9. 14
      sapl/templates/bootstrap3/layout/checkboxselectmultiple.html
  10. 19
      sapl/templates/bootstrap3/layout/radioselect.html
  11. 4
      sapl/test_urls.py
  12. 1
      sapl/utils.py

2
sapl/api/urls.py

@ -1,3 +1,4 @@
from django.conf import settings
from django.conf.urls import url, include
@ -5,7 +6,6 @@ from sapl.api.views import AutorListView
from .apps import AppConfig
app_name = AppConfig.name

3
sapl/api/views.py

@ -5,6 +5,8 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework.filters import DjangoFilterBackend
from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAuthenticated, AllowAny
from rest_framework.generics import ListAPIView, get_object_or_404
from rest_framework.viewsets import ModelViewSet
from sapl.api.forms import AutorChoiceFilterSet
from sapl.api.serializers import ChoiceSerializer, AutorSerializer,\
@ -99,6 +101,7 @@ class AutorListView(ListAPIView):
return ListAPIView.get(self, request, *args, **kwargs)
def get_queryset(self):
queryset = ListAPIView.get_queryset(self)

12
sapl/base/forms.py

@ -1,7 +1,9 @@
from crispy_forms.bootstrap import FieldWithButtons, InlineRadios, StrictButton
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Div, Field, Fieldset, Layout, Row
from crispy_forms.templatetags.crispy_forms_field import css_class
from django import forms
from django.conf import settings
from django.contrib.auth import get_user_model
@ -28,6 +30,12 @@ from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput,
from .models import AppConfig, CasaLegislativa
ACTION_CREATE_USERS_AUTOR_CHOICE = [
('C', _('Criar novo Usuário')),
('A', _('Associar um usuário existente')),
('N', _('Autor sem Usuário de Acesso ao Sapl')),
]
ACTION_CREATE_USERS_AUTOR_CHOICE = [
('C', _('Criar novo Usuário')),
@ -161,6 +169,7 @@ class AutorForm(ModelForm):
'como o Sistema deve proceder com o usuário que está sendo'
' desvinculado?'))
class Meta:
model = Autor
fields = ['tipo',
@ -181,8 +190,6 @@ class AutorForm(ModelForm):
StrictButton(
_('Filtrar'), css_class='btn-default btn-filtrar-autor',
type='button')),
css_class='hidden',
data_action='create',
data_application='AutorSearch',
@ -199,6 +206,7 @@ class AutorForm(ModelForm):
row2 = Row(to_column((InlineRadios('action_user'), 8)),
to_column((Div('username'), 4)))
row3 = Row(to_column(('senha', 3)),
to_column(('senha_confirma', 3)),
to_column(('email', 3)),

3
sapl/crud/base.py

@ -14,8 +14,8 @@ from django.db.models.fields.related import ForeignKey
from django.http.response import Http404
from django.utils.decorators import classonlymethod
from django.utils.encoding import force_text
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import string_concat
from django.views.generic import (CreateView, DeleteView, DetailView, ListView,
UpdateView)
from django.views.generic.base import ContextMixin
@ -25,7 +25,6 @@ from sapl.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display
from sapl.settings import BASE_DIR
from sapl.utils import normalize
logger = logging.getLogger(BASE_DIR.name)
ACTION_LIST, ACTION_CREATE, ACTION_DETAIL, ACTION_UPDATE, ACTION_DELETE = \

2
sapl/materia/forms.py

@ -1,5 +1,6 @@
from datetime import datetime
import django_filters
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout
from django import forms
@ -8,7 +9,6 @@ from django.db import models
from django.db.models import Max
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
import django_filters
from sapl.base.models import Autor
from sapl.comissoes.models import Comissao

1
sapl/materia/views.py

@ -37,7 +37,6 @@ from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label,
permissoes_protocoloadm, permission_required_for_app,
montar_row_autor)
from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm,
ConfirmarProposicaoForm, DocumentoAcessorioForm,
MateriaLegislativaFilterSet,

2
sapl/templates/base.html

@ -287,6 +287,8 @@
<script type="text/javascript" src="{% static 'js/jquery.runner.js' %}"></script>
<script type="text/javascript" src="{% static 'jquery-mask-plugin/dist/jquery.mask.js' %}"></script>
<script type="text/javascript" src="{% static 'drunken-parrot-flat-ui/js/checkbox.js' %}"></script>
<script type="text/javascript" src="{% static 'drunken-parrot-flat-ui/js/radio.js' %}"></script>
<script src="{% static 'tinymce/tinymce.min.js' %}"></script>
<script type="text/javascript" src="{% static 'jsdiff/diff.min.js' %}"></script>

7
sapl/templates/base/autor_form.html

@ -39,12 +39,12 @@ $(document).ready(function(){
active('pesquisa');
if (atualizar) {
var radios = $("#div_id_autor_related .controls").html('');
data.models.forEach(function (val, index) {
data.results.forEach(function (val, index) {
var html_radio = '<label class="radio"><span class="icons"><span class="first-icon"></span><span class="second-icon"></span></span><input type="radio" name="autor_related" id="id_autor_related_'+index+'" value="'+val.value+'">'+val.text+'</label>';
radios.append(html_radio);
});
if (data.models.length > 1) {
if (data.results.length > 1) {
$('input[name=autor_related]').change(function(event){
if (this.checked)
$('#id_q').val(event.target.parentElement.textContent);
@ -132,7 +132,8 @@ $(document).ready(function(){
});
$('input[name=action_user]:checked').trigger('change');
$('input[name=autor_related]').closest('.radio').remove();
if (flag_create)
$('input[name=autor_related]').closest('.radio').remove();
var pk = $('#id_tipo').val();
if (pk)

14
sapl/templates/bootstrap3/layout/checkboxselectmultiple.html

@ -0,0 +1,14 @@
{% load crispy_forms_filters %}
{% load l10n %}
<div class="controls controls-checkbox {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap3/layout/field_errors_block.html' %}
{% for choice in field.field.choices %}
<label class="checkbox{% if field.field.inline_class %} checkbox-inline{% endif %}{% if choice.0 in field.value or choice.0|stringformat:"s" in field.value or choice.0|stringformat:"s" == field.value|stringformat:"s" %} checked{% endif %}" for="id_{{ field.html_name }}_{{ forloop.counter }}">
<span class="icons"><span class="first-icon"></span><span class="second-icon fa fa-check"></span></span>
<input type="checkbox"{% if choice.0 in field.value or choice.0|stringformat:"s" in field.value or choice.0|stringformat:"s" == field.value|stringformat:"s" %} checked="checked"{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>{{ choice.1|unlocalize }}
</label>
{% endfor %}
{% include 'bootstrap3/layout/help_text.html' %}
</div>

19
sapl/templates/bootstrap3/layout/radioselect.html

@ -0,0 +1,19 @@
{% load crispy_forms_filters %}
{% load l10n %}
<div class="controls controls-radio {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap3/layout/field_errors_block.html' %}
{% for choice in field.field.choices %}
<label class="radio{% if field.field.inline_class %} radio-inline{% endif %}{% if choice.0 in field.value or choice.0|stringformat:"s" in field.value or choice.0|stringformat:"s" == field.value|stringformat:"s" %} checked{% endif %}" for="id_{{ field.html_name }}_{{ forloop.counter }}">
<span class="icons">
<span class="first-icon"></span>
<span class="second-icon"></span>
</span>
<input type="radio"{% if choice.0 in field.value or choice.0|stringformat:"s" in field.value or choice.0|stringformat:"s" == field.value|stringformat:"s" %} checked="checked"{% endif %} name="{{ field.html_name }}" id="id_{{ field.html_name }}_{{ forloop.counter }}" value="{{ choice.0|unlocalize }}" {{ field.field.widget.attrs|flatatt }}>{{ choice.1|unlocalize }}
</label>
{% endfor %}
{% include 'bootstrap3/layout/help_text.html' %}
</div>

4
sapl/test_urls.py

@ -1,3 +1,4 @@
import pytest
from django.apps import apps
from django.contrib.auth import get_user_model
from django.contrib.auth.management import _get_all_permissions
@ -7,7 +8,7 @@ from django.db import transaction
from django.utils.translation import string_concat
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _
import pytest
from django.utils.translation import string_concat
from sapl.crud.base import PermissionRequiredForAppCrudMixin
from sapl.materia.views import recuperar_materia
@ -16,7 +17,6 @@ from scripts.lista_urls import lista_urls
from .settings import SAPL_APPS
pytestmark = pytest.mark.django_db
sapl_appconfs = [apps.get_app_config(n[5:]) for n in SAPL_APPS]

1
sapl/utils.py

@ -4,6 +4,7 @@ from unicodedata import normalize as unicodedata_normalize
import hashlib
import logging
import magic
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button
from django import forms

Loading…
Cancel
Save