filtra davvero
This commit is contained in:
parent
8ed118a37b
commit
388b25d032
5 changed files with 15 additions and 7 deletions
|
@ -2,3 +2,4 @@ Django==2.2
|
|||
gunicorn==20.0.4
|
||||
pytz==2019.3
|
||||
sqlparse==0.3.1
|
||||
django-filter==2.4.0
|
||||
|
|
|
@ -7,7 +7,7 @@ function viewMap () {
|
|||
L.tileLayer(
|
||||
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
|
||||
).addTo(map)
|
||||
$.getJSON('/api/rapporti/get', function (data) {
|
||||
$.getJSON('/api/rapporti/get' + (new URL(document.URL).search), function (data) {
|
||||
for (var i in data.rapporti) {
|
||||
var p = data.rapporti[i]
|
||||
var marker = new RapportoMarker([p.lat, p.lng], {
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<form method="GET">
|
||||
|
||||
<div class="form-field-line">
|
||||
<label for="tiporadio">Osservazione fatta con</label>
|
||||
<select name="tiporadio" >
|
||||
<label for="tipo_radio__id">Osservazione fatta con</label>
|
||||
<select name="tipo_radio__id" >
|
||||
<option value="NA" disabled selected="selected">//</option>
|
||||
{% for tr in tipiradio %}
|
||||
<option value="{{tr.id}}"><strong>{{tr.nome}}</strong> - {{tr.descrizione|default:'' }}</option>
|
||||
|
|
|
@ -24,6 +24,7 @@ urlpatterns = [
|
|||
path("", views.ViewMap.as_view(), name="home"),
|
||||
path("add", views.add_page, name="add"),
|
||||
path("api/rapporti/get", views.rapporti_get),
|
||||
# path("api/rapporti/get", views.RapportiGet.as_view()),
|
||||
path("api/rapporti/<int:pk>/edit", views.rapporto_edit_redirect),
|
||||
path("api/rapporti/add", views.rapporto_add),
|
||||
# path("api/rapporti/delete", views.rapporto_delete),
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue