editor url for missing locations too

This commit is contained in:
Laura Klünder 2019-12-25 10:46:27 +01:00
parent e70654b4b7
commit bc3806c53e
4 changed files with 20 additions and 4 deletions

View file

@ -22,6 +22,16 @@ editor = {
editor.map.doubleClickZoom.enable();
});
let $map = $('#map');
if ($map.is('[data-x][data-y]')) {
L.marker(
L.GeoJSON.coordsToLatLng([
parseFloat($map.attr('data-x')),
parseFloat($map.attr('data-y'))
]),
).addTo(editor.map);
}
if (window.mobileclient) {
var $body = $('body');
$body.addClass('mobileclient');

View file

@ -17,7 +17,7 @@
{% endblock %}
{% block content %}
<div id="map"></div>
<div id="map"{% if request.GET.x %} data-x="{{ request.GET.x }}"{% endif %}{% if request.GET.y %} data-y="{{ request.GET.y }}"{% endif %}></div>
<div id="sidebar">
<div class="content">{{ content | safe }}</div>
</div>

View file

@ -165,6 +165,12 @@ class Report(models.Model):
@cached_property
def editor_url(self):
if self.category == 'missing-location':
space = self.coordinates.space
if space is not None:
return reverse('editor.spaces.detail', kwargs={
'pk': space.pk,
'level': space.level_id,
})+'?x=%.2f&y=%.2f' % (self.coordinates.x, self.coordinates.y)
return None
elif self.category == 'location-issue':
location = self.location_specific

View file

@ -5,16 +5,16 @@
<p>
<a href="/l/{{ report.location_specific.slug }}/">{% trans 'open in c3nav' %}</a>
{% if report.editor_url %}
<a href="{{ editor_url }}">{% trans 'open in editor' %}</a>
<a href="{{ report.editor_url }}">{% trans 'open in editor' %}</a>
{% endif %}
</p>
{% elif report.category == 'missing-location' %}
<p><strong>{% trans 'You are reporting an missing location at the following position:' %}</strong></p>
{% include 'site/fragment_location.html' with form_value=1 location=report.coordinates add_subtitle=report.coordinates_id %}
<p>
<a href="/l/{{ report.coordinates.pk }}/">{% trans 'open in c3nav' %}</a>
<a href="/l/{{ report.coordinates.pk }}/">{% trans 'open in c3nav' %}</a>
{% if report.editor_url %}
<a href="{{ editor_url }}">{% trans 'open in editor' %}</a>
<a href="{{ report.editor_url }}">{% trans 'open in editor' %}</a>
{% endif %}
</p>
{% elif report.category == 'route-issue' %}