|
@@ -1,8 +1,9 @@
|
|
|
+import django_filters
|
|
|
from django.conf import settings
|
|
|
from django.http import JsonResponse
|
|
|
from django.shortcuts import redirect, render
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
-from django.views.generic import TemplateView
|
|
|
+from django.views.generic import ListView, TemplateView
|
|
|
|
|
|
from .models import RapportoRicezione, TipoRadio, User
|
|
|
|
|
@@ -27,10 +28,15 @@ def add_page(request):
|
|
|
)
|
|
|
|
|
|
|
|
|
+class RapportiFilter(django_filters.FilterSet):
|
|
|
+ class Meta:
|
|
|
+ model = RapportoRicezione
|
|
|
+ fields = ["tipo_radio__id"]
|
|
|
+
|
|
|
+
|
|
|
def rapporti_get(request):
|
|
|
- return JsonResponse(
|
|
|
- dict(rapporti=[r.serialize() for r in RapportoRicezione.objects.all()])
|
|
|
- )
|
|
|
+ pf = RapportiFilter(request.GET, queryset=RapportoRicezione.objects.all())
|
|
|
+ return JsonResponse(dict(rapporti=[r.serialize() for r in pf.qs]))
|
|
|
|
|
|
|
|
|
def rapporto_edit_redirect(request, pk):
|