Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dbchiro
dbchiroweb
Commits
5a947332
Commit
5a947332
authored
Apr 11, 2021
by
hypsug0
Browse files
Improve perfs and fix specie input on search form
parent
5913a469
Changes
3
Hide whitespace changes
Inline
Side-by-side
sights/mixins.py
View file @
5a947332
...
...
@@ -452,8 +452,10 @@ class PlaceFilteringMixin:
def
get_queryset
(
self
,
*
args
,
**
kwargs
):
qs
=
(
Place
.
objects
.
select_related
(
"municipality"
)
.
select_related
(
"metaplace"
)
.
select_related
(
"creator"
)
.
select_related
(
"type"
)
.
select_related
(
"territory"
)
)
municipality
=
self
.
request
.
query_params
.
get
(
"municipality"
,
None
)
...
...
sights/observation/api.py
View file @
5a947332
...
...
@@ -2,6 +2,7 @@
import
logging
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
django.db.models
import
Prefetch
from
rest_framework.generics
import
ListAPIView
from
rest_framework.permissions
import
AllowAny
,
IsAuthenticated
...
...
@@ -37,13 +38,11 @@ class GeoJSONSighting(
def
get_queryset
(
self
,
*
args
,
**
kwargs
):
qs
=
super
(
GeoJSONSighting
,
self
).
get_queryset
()
qs
=
qs
.
select_related
(
"created_by"
,
"codesp"
,
"session"
,
"session__contact"
,
"session__place"
,
"session__place__municipality"
,
qs
=
qs
.
select_related
(
"created_by"
,
"codesp"
,
"session"
,).
prefetch_related
(
Prefetch
(
"session__contact"
),
Prefetch
(
"session__place"
),
Prefetch
(
"session__place__municipality"
),
Prefetch
(
"session__place__territory"
),
)
return
qs
.
distinct
().
order_by
(
"-timestamp_update"
)
...
...
templates/sights/sighting_search.html
View file @
5a947332
...
...
@@ -70,13 +70,14 @@
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"place_type"
name=
"place_type"
placeholder=
"Type de localité"
>
</div>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"count_min"
>
Effectif mini
</label>
<input
class=
"form-control form-control-sm"
type=
"number"
id=
"count_min"
name=
"count_min"
placeholder=
"Effectif mini"
>
</div>
</div>
<div
class=
"form-row"
>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"specie"
>
Espèce
</label>
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"specie"
name=
"specie"
placeholder=
"Espèce"
>
</div>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"sex"
>
Sexe
</label>
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"sex"
name=
"sex"
...
...
@@ -92,6 +93,11 @@
<label
for=
"age"
>
Age
</label>
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"age"
name=
"age"
placeholder=
"Age"
>
</div>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"count_min"
>
Effectif mini
</label>
<input
class=
"form-control form-control-sm"
type=
"number"
id=
"count_min"
name=
"count_min"
placeholder=
"Effectif mini"
>
</div>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment