Create the unique_id in the template (vs. model)
This commit is contained in:
parent
c9b4b96c01
commit
7ff543e1d5
3 changed files with 33 additions and 29 deletions
|
@ -194,10 +194,6 @@ class Map(NamedModel):
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
public = PublicManager()
|
public = PublicManager()
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
return f"map_{self.pk}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preview_settings(self):
|
def preview_settings(self):
|
||||||
from .views import _urls_for_js
|
from .views import _urls_for_js
|
||||||
|
|
|
@ -13,31 +13,33 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for map_inst in maps %}
|
{% for map_inst in maps %}
|
||||||
{{ map_inst.preview_settings|json_script:map_inst.unique_id }}
|
{% with unique_id="map_"|addstr:map_inst.pk %}
|
||||||
<tr>
|
{{ map_inst.preview_settings|json_script:unique_id }}
|
||||||
<td>
|
<tr>
|
||||||
<a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a>
|
<td>
|
||||||
<button class="map-opener" data-map-id="{{ map_inst.unique_id }}">{% blocktrans %}Preview{% endblocktrans %}</button>
|
<a href="{{ map_inst.get_absolute_url }}">{{ map_inst.name }}</a>
|
||||||
<dialog>
|
<button class="map-opener" data-map-id="{{ unique_id }}">{% blocktrans %}Preview{% endblocktrans %}</button>
|
||||||
<form method="dialog">
|
<dialog>
|
||||||
<div id="{{ map_inst.unique_id }}_target" class="map_fragment"></div>
|
<form method="dialog">
|
||||||
<p class="close-dialog">
|
<div id="{{ unique_id }}_target" class="map_fragment"></div>
|
||||||
<button type="submit">Close</button>
|
<p class="close-dialog">
|
||||||
</p>
|
<button type="submit">Close</button>
|
||||||
</form>
|
</p>
|
||||||
</dialog>
|
</form>
|
||||||
</td>
|
</dialog>
|
||||||
<td>{{ map_inst.get_share_status_display }} / {{ map_inst.get_edit_status_display }}</td>
|
</td>
|
||||||
<td>{{ map_inst.modified_at }}</td>
|
<td>{{ map_inst.get_share_status_display }} / {{ map_inst.get_edit_status_display }}</td>
|
||||||
<td>
|
<td>{{ map_inst.modified_at }}</td>
|
||||||
<a href="{{ map_inst.owner.get_url }}">{{ map_inst.owner }}</a>
|
<td>
|
||||||
</td>
|
<a href="{{ map_inst.owner.get_url }}">{{ map_inst.owner }}</a>
|
||||||
<td>
|
</td>
|
||||||
<a href="{{ map_inst.get_absolute_url }}?share">{% translate "Share" %}</a> |
|
<td>
|
||||||
<a href="{{ map_inst.get_absolute_url }}?edit">{% translate "Edit" %}</a> |
|
<a href="{{ map_inst.get_absolute_url }}?share">{% translate "Share" %}</a> |
|
||||||
<a href="{% url 'map_download' map_inst.pk %}">{% translate "Download" %}</a>
|
<a href="{{ map_inst.get_absolute_url }}?edit">{% translate "Edit" %}</a> |
|
||||||
</td>
|
<a href="{% url 'map_download' map_inst.pk %}">{% translate "Download" %}</a>
|
||||||
</tr>
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endwith %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -60,3 +60,9 @@ def ipdb(what):
|
||||||
|
|
||||||
ipdb.set_trace()
|
ipdb.set_trace()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def addstr(arg1, arg2):
|
||||||
|
# Necessity: https://stackoverflow.com/a/23783666
|
||||||
|
return str(arg1) + str(arg2)
|
||||||
|
|
Loading…
Reference in a new issue