refactor(assets): remove specific naturegreensurface template in favor of detail_generic
This commit is contained in:
parent
b813de3984
commit
45bc88d1a3
3 changed files with 12 additions and 166 deletions
|
|
@ -1,44 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
const map = new maplibregl.Map({
|
|
||||||
style: window.MAP_STYLE_LIGHT,
|
|
||||||
center: [feature_lon, feature_lat],
|
|
||||||
zoom: 17,
|
|
||||||
pitch: 45,
|
|
||||||
bearing: -17.6,
|
|
||||||
container: 'map',
|
|
||||||
antialias: true
|
|
||||||
});
|
|
||||||
|
|
||||||
map.on('load', () => {
|
|
||||||
|
|
||||||
const featureData = {
|
|
||||||
type: 'FeatureCollection',
|
|
||||||
features: [
|
|
||||||
{
|
|
||||||
type: 'Feature',
|
|
||||||
geometry: JSON.parse(feature_geojson),
|
|
||||||
properties: {
|
|
||||||
name: '...'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add the circle as a GeoJSON source
|
|
||||||
map.addSource('green', {
|
|
||||||
type: 'geojson',
|
|
||||||
data: featureData
|
|
||||||
});
|
|
||||||
|
|
||||||
map.addLayer({
|
|
||||||
'id': 'green',
|
|
||||||
'type': 'fill',
|
|
||||||
'source': 'green',
|
|
||||||
'paint': {
|
|
||||||
'fill-color': '#0094ff',
|
|
||||||
'fill-opacity': 0.8
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row mt-2" style="height: calc(100vh - 200px);">
|
|
||||||
<div class="col-md-8" style="max-height: calc(100vh - 200px); overflow: auto;">
|
|
||||||
<h3 class="h3">
|
|
||||||
<i class="bi bi-suit-club"></i><span class="mx-2">{{ asset.code}}</span>
|
|
||||||
</h3>
|
|
||||||
<hr>
|
|
||||||
<div class="row mb-4">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label class="mx-2">Statut:</label><i class="bi bi-circle-fill status_{{ asset.status }}"></i> {{ asset.get_status_display }}<br>
|
|
||||||
<label class="mx-2">Type:</label>{{ asset.model.name_fr|default:"" }}<br>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6">
|
|
||||||
{% if asset.lon %}
|
|
||||||
<a href="https://www.google.com/maps?cbll={{ asset.lat|floatformat:'6u'}},{{ asset.lon|floatformat:'6u'}}&cbp=12,0,0,0,5&layer=c&panoid=" target="_blank" style="text-decoration: none; font-size: 16px; display: flex; align-items: center;">
|
|
||||||
<img src="{% static 'common/google-street-view-logo.png' %}" alt="Street View" height="20" style="margin-right: 8px;">
|
|
||||||
View in Google Street View
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-4">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<label class="mx-2">Densité:</label>{{ asset.density }}<br>
|
|
||||||
<label class="mx-2">Pondération:</label>{{ asset.weighting }}<br>
|
|
||||||
<label class="mx-2">Fréquence de tonte:</label>{{ asset.weighting }}<br>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row mb-4">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label class="mx-2">Dernier entretien:</label>{{ asset.last_preventive_date|default:"" }}<br>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Documents -->
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">
|
|
||||||
<h4>Documents</h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row">
|
|
||||||
{% for document in asset.documents.all %}
|
|
||||||
<div class="col-md-2 mb-3">
|
|
||||||
<a href="{{ document.file.url }}" target="_blank">
|
|
||||||
<div class="img-thumbnail" style="width: 100%; height: 100px; overflow: hidden;">
|
|
||||||
{% if document.thumbnail %}
|
|
||||||
<img src="{{ document.thumbnail.url }}" alt="{{ document.file.name }}" style="width: 100%; height: 100%; object-fit: cover; object-position: center;">
|
|
||||||
{% else %}
|
|
||||||
<img src="{{ document.file.url }}" alt="{{ document.file.name }}" style="width: 100%; height: 100%; object-fit: cover; object-position: center;">
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Interventions -->
|
|
||||||
<div class="card mb-4">
|
|
||||||
<div class="card-header">
|
|
||||||
<h4>Interventions</h4>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<table id="interventions-table" class="table"
|
|
||||||
data-height="550"
|
|
||||||
data-pagination="true"
|
|
||||||
data-page-size="25"
|
|
||||||
data-click-to-select="true" >
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-field="actions" data-width="100"></th>
|
|
||||||
<th data-field="code">Code</th>
|
|
||||||
<th data-field="title">Titre</th>
|
|
||||||
<th data-field="begin_date">Début</th>
|
|
||||||
<th data-field="statut">Statut</th>
|
|
||||||
</tr>
|
|
||||||
<tbody>
|
|
||||||
{% for interv in interventions %}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="{% url 'interventions:interventions_index' %}{{ interv.id }}" type="button" class="btn btn-sm btn-light detail-btn" data-id="${row.id}" data-bs-toggle="tooltip" title="Detail">
|
|
||||||
<i class="bi bi-info-circle"></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>{{ interv.code }}</td>
|
|
||||||
<td>{{ interv.title }}</td>
|
|
||||||
<td>{{ interv.begin_time|date:"d-m-Y H:i" }}</td>
|
|
||||||
<td>{{ interv.get_status_display }}</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div id="map">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock content%}
|
|
||||||
|
|
||||||
|
|
||||||
{% block script %}
|
|
||||||
{{ asset.lon|json_script:"lon_value" }}
|
|
||||||
{{ asset.lat|json_script:"lat_value" }}
|
|
||||||
{{ asset.geojson|json_script:"geojson_value" }}
|
|
||||||
<script>
|
|
||||||
const feature_geojson = JSON.parse(document.getElementById("geojson_value").textContent);
|
|
||||||
const feature_lon = JSON.parse(document.getElementById("lon_value").textContent);
|
|
||||||
const feature_lat = JSON.parse(document.getElementById("lat_value").textContent);
|
|
||||||
</script>
|
|
||||||
<script src="{% static 'assets/green_detail.js' %}"></script>
|
|
||||||
{% endblock script %}
|
|
||||||
|
|
@ -5686,3 +5686,15 @@ class NatureLocationDetailViewTest(TestCase):
|
||||||
self.assertContains(response, "Aucun arbre enregistré")
|
self.assertContains(response, "Aucun arbre enregistré")
|
||||||
self.assertContains(response, "layer-switcher-control.js")
|
self.assertContains(response, "layer-switcher-control.js")
|
||||||
|
|
||||||
|
def test_nature_greensurface_detail_view_uses_generic_template(self):
|
||||||
|
self.client.force_login(self.user)
|
||||||
|
url = reverse('assets:nature_assets_detail', kwargs={'asset_model': 'naturegreensurface', 'asset_id': self.gs1.id})
|
||||||
|
response = self.client.get(url)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertTemplateUsed(response, 'assets/detail_generic.html')
|
||||||
|
self.assertTemplateNotUsed(response, 'assets/naturegreensurface_detail.html')
|
||||||
|
self.assertContains(response, "GS-001")
|
||||||
|
self.assertContains(response, 'id="asset-map"')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue