Commit 0995f942 authored by Hypsug0's avatar Hypsug0
Browse files

wip: new sighting form

parent 097cbffd
......@@ -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);
};
}
This diff is collapsed.
......@@ -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:
......
......@@ -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"}),
......
......@@ -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
......@@ -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',
......
{% 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 %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment