Skip to content
GitLab
Menu
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
5e37ed7b
Commit
5e37ed7b
authored
Feb 16, 2020
by
Hypsug0
Browse files
emtpy choice as default contact in session form
parent
f8df06ac
Changes
5
Hide whitespace changes
Inline
Side-by-side
sights/forms.py
View file @
5e37ed7b
...
...
@@ -11,7 +11,7 @@ from django.utils.translation import ugettext_lazy as _
from
leaflet.forms.widgets
import
LeafletWidget
from
core.forms
import
PrimaryAccordionGroup
,
InfoAccordionGroup
,
DangerAccordionGroup
from
dicts.models
import
TypeDevice
,
Method
,
CountPrecision
,
CountUnit
from
dicts.models
import
TypeDevice
,
Method
,
CountPrecision
,
CountUnit
,
Contact
from
management.models
import
Transmitter
from
.models
import
(
MetaPlace
,
...
...
@@ -847,6 +847,8 @@ class SessionForm(forms.ModelForm):
self
.
helper
=
FormHelper
()
self
.
helper
.
form_method
=
"post"
self
.
helper
.
form_action
=
"submit"
self
.
base_fields
[
"contact"
].
empty_label
=
"Choisissez un type de contact"
self
.
base_fields
[
"contact"
].
initial
=
0
place_id
=
kwargs
.
pop
(
"place_id"
,
None
)
if
place_id
:
cancel_url
=
reverse
(
"sights:place_detail"
,
kwargs
=
{
"pk"
:
place_id
})
...
...
sights/observation/api.py
View file @
5e37ed7b
...
...
@@ -26,7 +26,8 @@ class GeoJSONSighting(LoginRequiredMixin, generics.ListAPIView):
specie
=
self
.
request
.
query_params
.
get
(
"specie"
,
None
)
count_min
=
self
.
request
.
query_params
.
get
(
"count_min"
,
None
)
count_max
=
self
.
request
.
query_params
.
get
(
"count_max"
,
None
)
type
=
self
.
request
.
query_params
.
get
(
"type"
,
None
)
place_type
=
self
.
request
.
query_params
.
get
(
"place_type"
,
None
)
contact_type
=
self
.
request
.
query_params
.
get
(
"contact_type"
,
None
)
alt_min
=
self
.
request
.
query_params
.
get
(
"alt_min"
,
None
)
alt_max
=
self
.
request
.
query_params
.
get
(
"alt_max"
,
None
)
gite
=
self
.
request
.
query_params
.
get
(
"gite"
,
None
)
...
...
@@ -47,14 +48,18 @@ class GeoJSONSighting(LoginRequiredMixin, generics.ListAPIView):
Q
(
session__place__municipality__name__icontains
=
municipality
)
|
Q
(
session__place__municipality__code__icontains
=
municipality
)
)
print
(
"unaccent"
,
qs
)
if
name
is
not
None
:
qs
=
qs
.
filter
(
session__place__name__icontains
=
name
)
if
type
is
not
None
:
if
place_
type
is
not
None
:
qs
=
qs
.
filter
(
Q
(
session__place__type__code__icontains
=
type
)
|
Q
(
session__place__type__category__icontains
=
type
)
|
Q
(
session__place__type__descr__icontains
=
type
)
Q
(
session__place__type__code__icontains
=
place_type
)
|
Q
(
session__place__type__category__icontains
=
place_type
)
|
Q
(
session__place__type__descr__icontains
=
place_type
)
)
if
contact_type
is
not
None
:
qs
=
qs
.
filter
(
Q
(
session__contact__code__icontains
=
contact_type
)
|
Q
(
session__contact__descr__icontains
=
contact_type
)
)
if
alt_min
is
not
None
:
qs
=
qs
.
filter
(
session__place__altitude__gte
=
alt_min
)
...
...
templates/sights/place_map.html
View file @
5e37ed7b
...
...
@@ -45,6 +45,9 @@
var
placeBaseUrl
=
'
/place/bbox/api/search
'
;
var
metaplaceBaseUrl
=
'
/metaplace/api/search
'
;
const
controller
=
new
AbortController
();
const
signal
=
controller
.
signal
;
window
.
addEventListener
(
"
map:init
"
,
function
(
event
)
{
var
markers
=
L
.
markerClusterGroup
({
chunkedLoading
:
true
,
...
...
@@ -143,7 +146,8 @@
map
.
spin
(
true
);
var
dataBboxUrl
=
placeBaseUrl
+
'
?format=json&in_bbox=
'
+
map
.
getBounds
().
toBBoxString
();
fetch
(
dataBboxUrl
,
{
credentials
:
"
include
"
credentials
:
"
include
"
,
signal
:
signal
,
})
.
then
(
function
(
resp
)
{
return
resp
.
json
();
...
...
@@ -183,12 +187,15 @@
});
};
var
debounce
=
null
;
map
.
on
(
'
moveend
'
,
function
()
{
var
currZoom
=
map
.
getZoom
();
if
(
currZoom
>=
13
)
{
map
.
removeControl
(
overlayText
);
markers
.
clearLayers
();
placeData
();
clearTimeout
(
debounce
);
debounce
=
setTimeout
(
placeData
,
1000
);
}
else
{
markers
.
clearLayers
();
overlayText
.
addTo
(
map
);
...
...
@@ -196,7 +203,7 @@
});
// Download GeoJSON data with Ajax
fetch
(
metaplaceBaseUrl
+
'
?format=json
'
,
{
credentials
:
"
include
"
})
fetch
(
metaplaceBaseUrl
+
'
?format=json
'
,
{
credentials
:
"
include
"
})
.
then
(
function
(
resp
)
{
return
resp
.
json
();
})
...
...
templates/sights/place_search.html
View file @
5e37ed7b
...
...
@@ -160,7 +160,13 @@
</div>
<script>
var
dataUrl
=
"
/place/api/search?format=json
"
;
const
controller
=
new
AbortController
();
const
signal
=
controller
.
signal
;
var
cancelDataLoad
=
function
()
{
console
.
log
(
'
cancel load
'
);
controller
.
abort
();
};
$
(
document
).
ready
(
function
()
{
function
format
(
d
)
{
...
...
@@ -212,7 +218,7 @@
},
dom
:
'
Btri
'
,
paging
:
false
,
scrollY
:
'
500px
'
,
scrollY
:
'
500px
'
,
buttons
:
[
'
excel
'
],
...
...
@@ -436,10 +442,12 @@
// Download GeoJSON data with Ajax
var
markersById
=
{}
const
loadPlaces
=
function
()
{
cancelDataLoad
();
markers
.
clearLayers
();
searchMap
.
spin
(
true
);
fetch
(
dataUrl
,
{
credentials
:
"
include
"
credentials
:
"
include
"
,
signal
:
signal
,
})
.
then
(
function
(
resp
)
{
return
resp
.
json
();
...
...
templates/sights/sighting_search.html
View file @
5e37ed7b
...
...
@@ -82,9 +82,9 @@
<label
class=
"form-check-label"
for=
"breed_colo"
>
Colonie de reproduction
</label>
</div>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"type"
>
Type
</label>
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"type"
name=
"type"
placeholder=
"Type"
>
<label
for=
"
place_
type"
>
Type
de localité
</label>
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"
place_
type"
name=
"
place_
type"
placeholder=
"Type
de localité
"
>
</div>
</div>
<div
class=
"form-row"
>
...
...
@@ -146,6 +146,12 @@
</div>
</div>
<div
class=
"form-row"
>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"contact_type"
>
Type de contact
</label>
<input
class=
"form-control form-control-sm"
type=
"text"
id=
"contact_type"
name=
"contact_type"
placeholder=
"Type de contact"
>
</div>
<div
class=
"form-group form-group-sm mr-2"
>
<label
for=
"alt_min"
>
Altitude mini
</label>
<input
class=
"form-control form-control-sm"
type=
"number"
id=
"alt_min"
...
...
@@ -219,7 +225,7 @@
url
:
dataUrl
,
dataSrc
:
"
features
"
},
language
:
{
language
:
{
processing
:
"
Traitement en cours...
"
,
search
:
"
Rechercher :
"
,
lengthMenu
:
"
Afficher _MENU_ éléments
"
,
...
...
@@ -243,7 +249,7 @@
},
{
#
dom
:
'
Btri
'
,
#
}
paging
:
false
,
scrollY
:
'
500px
'
,
scrollY
:
'
500px
'
,
searching
:
false
,
columns
:
[
{
...
...
Hypsug0
@fred.perso
mentioned in issue
#51 (closed)
·
Feb 16, 2020
mentioned in issue
#51 (closed)
mentioned in issue #51
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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