create dedicated tile for goto page (if required)

This commit is contained in:
Frédéric Péters 2018-09-16 17:06:36 +02:00
parent 2946e979fa
commit 38625f6a65
1 changed files with 16 additions and 1 deletions

View File

@ -38,7 +38,7 @@ from django.utils.safestring import mark_safe
from combo.apps.dashboard.models import DashboardCell
from combo.apps.maps.models import Map, MapLayer
from combo.data.models import Page, ConfigJsonCell
from combo.data.models import Page, CellBase, ConfigJsonCell
from combo.public.views import render_cell
from combo.utils import requests
@ -692,3 +692,18 @@ def json_script(value, element_id):
'<script id="{}" type="application/json">{}</script>',
element_id, mark_safe(json_str)
)
@register.assignment_tag
def get_goto_cell(page, request):
try:
cell = ConfigJsonCell.objects.get(id=request.GET['to'])
except (ConfigJsonCell.DoesNotExist, KeyError):
return None
if cell.page.template_name != 'place':
return cell
# create an alternate version of cell
cell.id = None
cell.placeholder = '_auto_tile'
cell.page = page
cell.save()
return cell