Browse Source

alterações mínimas para executar manage check

pull/2446/head
Leandro Roberto 6 years ago
parent
commit
5596388326
  1. 2
      sapl/api/forms.py
  2. 5
      sapl/api/views.py
  3. 7
      sapl/settings.py
  4. 21
      sapl/utils.py

2
sapl/api/forms.py

@ -6,8 +6,8 @@ from django.forms.widgets import MultiWidget, TextInput
from django.utils import timezone from django.utils import timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django_filters.filters import CharFilter, ModelChoiceFilter, DateFilter from django_filters.filters import CharFilter, ModelChoiceFilter, DateFilter
from django_filters.rest_framework.filterset import FilterSet
from rest_framework import serializers from rest_framework import serializers
from rest_framework.filters import FilterSet
from sapl.base.models import Autor, TipoAutor from sapl.base.models import Autor, TipoAutor
from sapl.parlamentares.models import Legislatura from sapl.parlamentares.models import Legislatura

5
sapl/api/views.py

@ -1,9 +1,10 @@
import logging import logging
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.db.models import Q from django.db.models import Q
from django.http import Http404 from django.http import Http404
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework.filters import DjangoFilterBackend from django_filters.rest_framework.backends import DjangoFilterBackend
from rest_framework.generics import ListAPIView from rest_framework.generics import ListAPIView
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
from rest_framework.permissions import (AllowAny, IsAuthenticated, from rest_framework.permissions import (AllowAny, IsAuthenticated,
@ -175,7 +176,7 @@ class AutoresProvaveisListView(ListAPIView):
serializer_class = ChoiceSerializer serializer_class = ChoiceSerializer
def get_queryset(self): def get_queryset(self):
params = {'content_type__isnull': False} params = {'content_type__isnull': False}
username = self.request.user.username username = self.request.user.username
tipo = '' tipo = ''

7
sapl/settings.py

@ -90,6 +90,7 @@ INSTALLED_APPS = (
'haystack', 'haystack',
'sass_processor', 'sass_processor',
'rest_framework', 'rest_framework',
'django_filters',
'reversion', 'reversion',
'reversion_compare', 'reversion_compare',
'whoosh', 'whoosh',
@ -110,7 +111,7 @@ SOLR_URL = config('SOLR_URL', cast=str, default='http://localhost:8983')
SOLR_COLLECTION = config('SOLR_COLLECTION', cast=str, default='sapl') SOLR_COLLECTION = config('SOLR_COLLECTION', cast=str, default='sapl')
if USE_SOLR: if USE_SOLR:
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' #enable auto-index HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' # enable auto-index
SEARCH_BACKEND = 'haystack.backends.solr_backend.SolrEngine' SEARCH_BACKEND = 'haystack.backends.solr_backend.SolrEngine'
SEARCH_URL = ('URL', '{}/solr/{}'.format(SOLR_URL, SOLR_COLLECTION)) SEARCH_URL = ('URL', '{}/solr/{}'.format(SOLR_URL, SOLR_COLLECTION))
@ -118,7 +119,7 @@ if USE_SOLR:
HAYSTACK_CONNECTIONS = { HAYSTACK_CONNECTIONS = {
'default': { 'default': {
'ENGINE': SEARCH_BACKEND, 'ENGINE': SEARCH_BACKEND,
SEARCH_URL[0]: SEARCH_URL[1], SEARCH_URL[0]: SEARCH_URL[1],
'BATCH_SIZE': 1000, 'BATCH_SIZE': 1000,
'TIMEOUT': 60, 'TIMEOUT': 60,
}, },
@ -166,7 +167,7 @@ REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "sapl.api.pagination.StandardPagination", "DEFAULT_PAGINATION_CLASS": "sapl.api.pagination.StandardPagination",
"DEFAULT_FILTER_BACKENDS": ( "DEFAULT_FILTER_BACKENDS": (
"rest_framework.filters.SearchFilter", "rest_framework.filters.SearchFilter",
"rest_framework.filters.DjangoFilterBackend", 'django_filters.rest_framework.DjangoFilterBackend',
), ),
} }

21
sapl/utils.py

@ -21,7 +21,6 @@ from django.db.models import Q
from django.utils import six, timezone from django.utils import six, timezone
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import django_filters import django_filters
from django_filters.filterset import STRICTNESS
from easy_thumbnails import source_generators from easy_thumbnails import source_generators
from floppyforms import ClearableFileInput from floppyforms import ClearableFileInput
import magic import magic
@ -685,12 +684,12 @@ def qs_override_django_filter(self):
valid = self.is_bound and self.form.is_valid() valid = self.is_bound and self.form.is_valid()
if self.is_bound and not valid: if self.is_bound and not valid:
if self.strict == STRICTNESS.RAISE_VALIDATION_ERROR: """if self.strict == STRICTNESS.RAISE_VALIDATION_ERROR:
raise forms.ValidationError(self.form.errors) raise forms.ValidationError(self.form.errors)
elif bool(self.strict) == STRICTNESS.RETURN_NO_RESULTS: elif bool(self.strict) == STRICTNESS.RETURN_NO_RESULTS:"""
self._qs = self.queryset.none() self._qs = self.queryset.none()
return self._qs return self._qs
# else STRICTNESS.IGNORE... ignoring # else STRICTNESS.IGNORE... ignoring
# start with all the results and filter from there # start with all the results and filter from there
qs = self.queryset.all() qs = self.queryset.all()
@ -703,12 +702,12 @@ def qs_override_django_filter(self):
try: try:
value = self.form.fields[name].clean(raw_value) value = self.form.fields[name].clean(raw_value)
except forms.ValidationError: except forms.ValidationError:
if self.strict == STRICTNESS.RAISE_VALIDATION_ERROR: """if self.strict == STRICTNESS.RAISE_VALIDATION_ERROR:
raise raise
elif bool(self.strict) == STRICTNESS.RETURN_NO_RESULTS: elif bool(self.strict) == STRICTNESS.RETURN_NO_RESULTS:"""
self._qs = self.queryset.none() self._qs = self.queryset.none()
return self._qs return self._qs
# else STRICTNESS.IGNORE... ignoring # else STRICTNESS.IGNORE... ignoring
if value is not None: # valid & clean data if value is not None: # valid & clean data
qs = qs._next_is_sticky() qs = qs._next_is_sticky()

Loading…
Cancel
Save