correcion de archivos, filter, utils, y eliminacion de llamados que no estan en uso
Showing
3 changed files
with
8 additions
and
10 deletions
1 | -from rest_framework import viewsets, filters, mixins, status, serializers | 1 | +from rest_framework import viewsets, filters, mixins, status |
2 | from django_filters.rest_framework import DjangoFilterBackend | 2 | from django_filters.rest_framework import DjangoFilterBackend |
3 | from rest_framework.response import Response | 3 | from rest_framework.response import Response |
4 | from rest_framework.permissions import IsAuthenticated | 4 | from rest_framework.permissions import IsAuthenticated |
@@ -11,7 +11,7 @@ from .filters import EdictoFilter, PrecioFilter | @@ -11,7 +11,7 @@ from .filters import EdictoFilter, PrecioFilter | ||
11 | from .pagination import CustomPagination | 11 | from .pagination import CustomPagination |
12 | from .permissions import IsAdminOrAuthorized | 12 | from .permissions import IsAdminOrAuthorized |
13 | from .utils import contador | 13 | from .utils import contador |
14 | -# from .precio import calculadora | 14 | + |
15 | 15 | ||
16 | 16 | ||
17 | class EdictoViewSet(mixins.CreateModelMixin, | 17 | class EdictoViewSet(mixins.CreateModelMixin, |
@@ -9,12 +9,10 @@ class EdictoFilter(filters.FilterSet): | @@ -9,12 +9,10 @@ class EdictoFilter(filters.FilterSet): | ||
9 | 9 | ||
10 | class Meta: | 10 | class Meta: |
11 | model = Edicto | 11 | model = Edicto |
12 | - fields = ('usuario', | ||
13 | - 'estado', | ||
14 | - 'fecha_creacion__gte', | ||
15 | - 'fecha_creacion__lte', | ||
16 | - 'id', | ||
17 | - ) | 12 | + fields = {'usuario': ['exact'], |
13 | + 'estado': ['exact'], | ||
14 | + 'id': ['exact'], | ||
15 | + } | ||
18 | 16 | ||
19 | 17 | ||
20 | class PrecioFilter(filters.FilterSet): | 18 | class PrecioFilter(filters.FilterSet): |
@@ -2,8 +2,8 @@ import re | @@ -2,8 +2,8 @@ import re | ||
2 | 2 | ||
3 | 3 | ||
4 | def contador(edicto): | 4 | def contador(edicto): |
5 | + expresiones = re.findall(r'\(\.\.\.', edicto) | ||
5 | edicto_sin_guiones = re.sub(r'(?<!\w)-|-(?!\w)', ' ', edicto) | 6 | edicto_sin_guiones = re.sub(r'(?<!\w)-|-(?!\w)', ' ', edicto) |
6 | palabras = re.split(r'\s+', edicto_sin_guiones) | 7 | palabras = re.split(r'\s+', edicto_sin_guiones) |
7 | - palabras_filtradas = [palabra for palabra in palabras if palabra.strip()] | ||
8 | - total_palabras = len(palabras_filtradas) | 8 | + total_palabras = len(palabras) + len(expresiones) |
9 | return total_palabras | 9 | return total_palabras |
-
Please register or login to post a comment