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
0995f942
Commit
0995f942
authored
Feb 01, 2021
by
Hypsug0
Browse files
wip: new sighting form
parent
097cbffd
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
core/static/js/app.js
View file @
0995f942
...
...
@@ -133,7 +133,7 @@ const placeSearchBlock = () => {
'
Modifier
'
,
'
info
'
,
'
fa-edit
'
,
`/place/
${
id
}
/
edit
`
`/place/
${
id
}
/
update
`
),
placeSearchActionButtons
(
'
Ajouter une observation détaillée
'
,
...
...
@@ -543,4 +543,24 @@ const placeSearchBlock = () => {
})
}
const
placeDetailMap
=
()
=>
{
const
map_init_basic
=
(
map
,
options
,
marker
)
=>
{
// Géolocalisation de l'utilisateur
var
locateOptions
=
{
flyTo
:
true
,
title
:
'
Ma position
'
,
icon
:
'
fa fa-location-arrow
'
,
};
L
.
control
.
locate
(
locateOptions
).
addTo
(
map
);
// Fonction plein écran
map
.
addControl
(
new
L
.
Control
.
Fullscreen
());
// Ajout du marker de la localité
L
.
geoJson
(
marker
).
addTo
(
map
);
map
.
fitBounds
(
L
.
geoJson
(
marker
).
getBounds
());
map
.
setZoom
(
13
);
};
}
core/static/js/vue.js
0 → 100644
View file @
0995f942
This diff is collapsed.
Click to expand it.
sights/forms.py
View file @
0995f942
...
...
@@ -1115,8 +1115,8 @@ class SightingForm(forms.ModelForm):
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
#
main_observer = kwargs.pop("main_observer", None)
#
other_observer = kwargs.pop("other_observer", None)
main_observer
=
kwargs
.
pop
(
"main_observer"
,
None
)
other_observer
=
kwargs
.
pop
(
"other_observer"
,
None
)
session_id
=
kwargs
.
pop
(
"session_id"
,
None
)
contact
=
kwargs
.
pop
(
"contact"
,
None
)
if
session_id
:
...
...
sights/observation/urls.py
View file @
0995f942
...
...
@@ -7,6 +7,7 @@ from sights.observation.views import (
SightingCreate
,
SightingDelete
,
SightingDetail
,
SightingEditForm
,
SightingMyList
,
SightingSearch
,
SightingUpdate
,
...
...
@@ -23,6 +24,7 @@ urlpatterns = [
path
(
"sighting/<int:pk>/update"
,
SightingUpdate
.
as_view
(),
name
=
"sighting_update"
),
path
(
"sighting/<int:pk>/delete"
,
SightingDelete
.
as_view
(),
name
=
"sighting_delete"
),
path
(
"sighting/api/search"
,
GeoJSONSighting
.
as_view
(),
name
=
"sighting_search_api"
),
path
(
"session/<int:pk>/sighting/edit"
,
SightingEditForm
.
as_view
(),
name
=
"sighting_edit_form"
),
path
(
"api/v1/session/<int:session>/sightings"
,
EditSighting
.
as_view
({
"get"
:
"list"
}),
...
...
sights/observation/views.py
View file @
0995f942
...
...
@@ -16,7 +16,12 @@ from django_tables2 import SingleTableView
from
django_tables2.export
import
ExportMixin
from
sights.forms
import
SightingForm
from
sights.mixins
import
AdvancedUserViewMixin
,
SightingEditAuthMixin
,
SightingViewAuthMixin
from
sights.mixins
import
(
AdvancedUserViewMixin
,
SessionEditAuthMixin
,
SightingEditAuthMixin
,
SightingViewAuthMixin
,
)
from
sights.models
import
CountDetail
,
Device
,
Session
,
Sighting
from
sights.tables
import
(
CountDetailAcousticTable
,
...
...
@@ -292,3 +297,14 @@ class SightingSearch(LoginRequiredMixin, TemplateView):
]
=
"""
"""
return
context
class
SightingEditForm
(
SessionEditAuthMixin
,
DetailView
):
model
=
Session
template_name
=
"sights/sighting_form.html"
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
SightingEditForm
,
self
).
get_context_data
(
**
kwargs
)
context
[
"icon"
]
=
"fa fa-eye fa-fw"
context
[
"title"
]
=
"Modification d'une observation"
return
context
templates/sights/place_detail.html
View file @
0995f942
...
...
@@ -156,12 +156,12 @@
<label>
Carte
</label>
{% leaflet_map "map" callback="window.map_init_basic" %}
<script
type=
"text/javascript"
>
var
marker
=
{{
object
.
geom
|
geojsonfeature
|
safe
}};
const
marker
=
{{
object
.
geom
|
geojsonfeature
|
safe
}};
function
map_init_basic
(
map
,
options
)
{
function
map_init_basic
(
map
,
options
)
{
// Géolocalisation de l'utilisateur
var
locateOptions
=
{
console
.
log
(
'
map_init_basic
'
,
map
)
const
locateOptions
=
{
flyTo
:
true
,
title
:
'
Ma position
'
,
icon
:
'
fa fa-location-arrow
'
,
...
...
templates/sights/sighting_form.html
0 → 100644
View file @
0995f942
{% extends 'base_fullwidth_leaflet.html' %}
{% load i18n static %}
{% block content %}
<script
src=
"{% static 'js/vue.js' %}"
></script>
<h1><i
class=
"{{ icon | safe }}"
></i>
{{ title | safe }}
</h1>
<div
id=
"sightingForm"
>
<span
class=
"label label-default"
>
[[data.results?.length]]
</span>
<div
v-for=
'r in data.results'
>
<div
><pre>
[[r]]
</pre></div>
<div
style=
"margin-left: 50px"
v-for=
'cd in r.countdetail_sighting'
><pre>
[[cd]]
</pre></div>
</div>
</div>
<script
type=
"application/javascript"
>
const
dataUrl
=
"
{% url 'sights:sighting_detail_api' session=object.pk %}
"
$
(
document
).
ready
(
function
()
{
const
vm
=
new
Vue
({
el
:
'
#sightingForm
'
,
delimiters
:
[
'
[[
'
,
'
]]
'
],
data
:
{
data
:
Object
,
},
mounted
()
{
$http
.
get
(
dataUrl
)
.
then
((
response
)
=>
(
this
.
data
=
response
.
data
))
},
// options
})
})
</script>
{% endblock %}
Write
Preview
Markdown
is supported
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