add space children pages
This commit is contained in:
parent
55f582a2c5
commit
57627a4d53
3 changed files with 33 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
{% for model in child_models %}
|
{% for model in child_models %}
|
||||||
<a href="{{ model.url }}" class="list-group-item">
|
<a href="{{ model.url }}" class="list-group-item">
|
||||||
{% if model.count %}<span class="badge">{{ model.count }}</span>{% endif %}
|
{% if model.count != None %}<span class="badge">{{ model.count }}</span>{% endif %}
|
||||||
{{ model.title }}
|
{{ model.title }}
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -28,3 +28,8 @@ urlpatterns.extend(add_editor_urls('sections', 'Section', with_list=False, expli
|
||||||
urlpatterns.extend(add_editor_urls('locationgroups', 'LocationGroup'))
|
urlpatterns.extend(add_editor_urls('locationgroups', 'LocationGroup'))
|
||||||
urlpatterns.extend(add_editor_urls('spaces', 'Space', 'sections', 'section', explicit_edit=True))
|
urlpatterns.extend(add_editor_urls('spaces', 'Space', 'sections', 'section', explicit_edit=True))
|
||||||
urlpatterns.extend(add_editor_urls('doors', 'Door', 'sections', 'section'))
|
urlpatterns.extend(add_editor_urls('doors', 'Door', 'sections', 'section'))
|
||||||
|
urlpatterns.extend(add_editor_urls('areas', 'Area', 'spaces', 'space'))
|
||||||
|
urlpatterns.extend(add_editor_urls('stairs', 'Stair', 'spaces', 'space'))
|
||||||
|
urlpatterns.extend(add_editor_urls('obstacles', 'Obstacle', 'spaces', 'space'))
|
||||||
|
urlpatterns.extend(add_editor_urls('lineobstacles', 'LineObstacle', 'spaces', 'space'))
|
||||||
|
urlpatterns.extend(add_editor_urls('points', 'Point', 'spaces', 'space'))
|
||||||
|
|
|
@ -8,8 +8,9 @@ from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.views.decorators.cache import never_cache
|
from django.views.decorators.cache import never_cache
|
||||||
|
|
||||||
from c3nav.mapdata.models import Door, LocationGroup, Section, Space
|
from c3nav.mapdata.models import Area, Door, LineObstacle, LocationGroup, Obstacle, Section, Space, Stair
|
||||||
from c3nav.mapdata.models.base import EDITOR_FORM_MODELS
|
from c3nav.mapdata.models.base import EDITOR_FORM_MODELS
|
||||||
|
from c3nav.mapdata.models.geometry.space import Point
|
||||||
|
|
||||||
|
|
||||||
def sidebar_view(func):
|
def sidebar_view(func):
|
||||||
|
@ -65,7 +66,27 @@ def space_detail(request, section, pk):
|
||||||
'section': space.section,
|
'section': space.section,
|
||||||
'space': space,
|
'space': space,
|
||||||
|
|
||||||
'child_models': [],
|
'child_models': [{
|
||||||
|
'title': Area._meta.verbose_name_plural,
|
||||||
|
'url': reverse('editor.areas.list', kwargs={'space': pk}),
|
||||||
|
'count': space.areas.count(),
|
||||||
|
}, {
|
||||||
|
'title': Stair._meta.verbose_name_plural,
|
||||||
|
'url': reverse('editor.stairs.list', kwargs={'space': pk}),
|
||||||
|
'count': space.stairs.count(),
|
||||||
|
}, {
|
||||||
|
'title': Obstacle._meta.verbose_name_plural,
|
||||||
|
'url': reverse('editor.obstacles.list', kwargs={'space': pk}),
|
||||||
|
'count': space.obstacles.count(),
|
||||||
|
}, {
|
||||||
|
'title': LineObstacle._meta.verbose_name_plural,
|
||||||
|
'url': reverse('editor.lineobstacles.list', kwargs={'space': pk}),
|
||||||
|
'count': space.lineobstacles.count(),
|
||||||
|
}, {
|
||||||
|
'title': Point._meta.verbose_name_plural,
|
||||||
|
'url': reverse('editor.points.list', kwargs={'space': pk}),
|
||||||
|
'count': space.points.count(),
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,7 +134,7 @@ def edit(request, pk=None, model=None, section=None, space=None, explicit_edit=F
|
||||||
elif hasattr(obj, 'space'):
|
elif hasattr(obj, 'space'):
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'section': obj.space.section,
|
'section': obj.space.section,
|
||||||
'back_url': reverse('editor.spaces.detail', kwargs={'pk': obj.space.pk}),
|
'back_url': reverse('editor.spaces.detail', kwargs={'section': obj.space.section.pk, 'pk': obj.space.pk}),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
@ -199,10 +220,11 @@ def list_objects(request, model=None, section=None, space=None, explicit_edit=Fa
|
||||||
})
|
})
|
||||||
elif space is not None:
|
elif space is not None:
|
||||||
reverse_kwargs['space'] = space
|
reverse_kwargs['space'] = space
|
||||||
space = get_object_or_404(Section, pk=space)
|
space = get_object_or_404(Space, pk=space)
|
||||||
queryset = queryset.filter(space=space)
|
queryset = queryset.filter(space=space)
|
||||||
ctx.update({
|
ctx.update({
|
||||||
'back_url': reverse('editor.spaces.detail', kwargs={'pk': space.pk}),
|
'section': space.section,
|
||||||
|
'back_url': reverse('editor.spaces.detail', kwargs={'section': space.section.pk, 'pk': space.pk}),
|
||||||
'back_title': _('back to space'),
|
'back_title': _('back to space'),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue