new editor index

This commit is contained in:
Laura Klünder 2017-05-16 12:34:45 +02:00
parent 7ba7affcfc
commit 678ed82391
5 changed files with 20 additions and 35 deletions

View file

@ -1,19 +1,19 @@
{% load static %} {% load static %}
{% load compress %} {% load compress %}
{% load i18n %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>c3nav Map Editor</title> <title>{% trans 'c3nav map editor' %}</title>
{% compress css %} {% compress css %}
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet"> <link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet">
<link href="{% static 'leaflet/leaflet.css' %}" rel="stylesheet"> <link href="{% static 'leaflet/leaflet.css' %}" rel="stylesheet">
<link href="{% static 'editor/css/editor.css' %}" rel="stylesheet"> <link href="{% static 'editor/css/editor.css' %}" rel="stylesheet">
{% endcompress %} {% endcompress %}
</head> </head>
<body> <body>
<nav class="navbar navbar-static-top navbar-default"> <nav class="navbar navbar-static-top navbar-default">

View file

@ -1,12 +1,10 @@
{% load bootstrap3 %} {% load bootstrap3 %}
{% load i18n %} {% load i18n %}
{% include 'editor/fragment_sections.html' %}
<a class="btn btn-default btn-sm pull-right" accesskey="n" href="{% url 'editor.sections' %}">{% trans 'Edit sections' %}</a> <h3>{% trans 'Sections' %}</h3>
<h3>{{ section.title }}</h3>
<div class="list-group"> <div class="list-group">
{% for s in sections %} {% for s in sections %}
<a href="{% url 'editor.index' section=s.id %}" class="list-group-item"> <a href="{% url 'editor.section' section=s.id %}" class="list-group-item">
{{ s.title }} {{ s.title }}
</a> </a>
{% endfor %} {% endfor %}

View file

@ -2,13 +2,9 @@
{% load i18n %} {% load i18n %}
{% include 'editor/fragment_sections.html' %} {% include 'editor/fragment_sections.html' %}
<a class="btn btn-default btn-sm pull-right" accesskey="n" href="">{% trans 'Add section' %}</a> <a class="btn btn-default btn-sm pull-right" accesskey="n" href="{% url 'editor.section.edit' section=section.id %}">{% trans 'Edit Section' %}</a>
<h3>{% trans 'Sections' %}</h3> <h3>{{ section.title }}</h3>
<div class="list-group"> <p>
{% for s in sections %} <a href="{% url 'editor.index' %}">&laquo; {% trans 'Back to overview' %}</a>
<a href="{% url 'editor.index' section=s.id %}" class="list-group-item{% if s == section %} active{% endif %}"> </p>
{{ s.title }}
</a>
{% endfor %}
</div>

View file

@ -1,11 +1,11 @@
from django.conf.urls import url from django.conf.urls import url
from c3nav.editor.views import edit_mapitem, list_mapitems, list_mapitemtypes, main_index, sections_list from c3nav.editor.views import edit_mapitem, list_mapitems, list_mapitemtypes, main_index, section_detail
urlpatterns = [ urlpatterns = [
url(r'^$', main_index, name='editor.index'), url(r'^$', main_index, name='editor.index'),
url(r'^sections/$', sections_list, name='editor.sections'), url(r'^sections/(?P<section>[0-9]+)/$', section_detail, name='editor.section'),
url(r'^sections/(?P<section>[0-9]+)/$', main_index, name='editor.index'), url(r'^sections/(?P<section>[0-9]+)/edit$', section_detail, name='editor.section.edit'),
url(r'^mapitemtypes/(?P<level>[^/]+)/$', list_mapitemtypes, name='editor.mapitemtypes'), url(r'^mapitemtypes/(?P<level>[^/]+)/$', list_mapitemtypes, name='editor.mapitemtypes'),
url(r'^mapitems/(?P<mapitem_type>[^/]+)/list/$', list_mapitems, name='editor.mapitems'), url(r'^mapitems/(?P<mapitem_type>[^/]+)/list/$', list_mapitems, name='editor.mapitems'),
url(r'^mapitems/(?P<mapitem_type>[^/]+)/list/(?P<sectionl>[0-9]+)/$', list_mapitems, name='editor.mapitems.level'), url(r'^mapitems/(?P<mapitem_type>[^/]+)/list/(?P<sectionl>[0-9]+)/$', list_mapitems, name='editor.mapitems.level'),

View file

@ -22,29 +22,20 @@ def sidebar_view(func):
@sidebar_view @sidebar_view
def main_index(request, section=None): def main_index(request, section=None):
if section is None:
first_section = Section.objects.first()
if first_section:
return render(request, 'editor/redirect.html', {
'target': reverse('editor.index', kwargs={'section': first_section.id})
})
else:
return render(request, 'editor/redirect.html', {
'target': reverse('editor.sections')
})
else:
section = get_object_or_404(Section, pk=section)
return render(request, 'editor/index.html', { return render(request, 'editor/index.html', {
'sections': Section.objects.all(), 'sections': Section.objects.all(),
'section': section,
'section_url': 'editor.index',
}) })
@sidebar_view @sidebar_view
def sections_list(request): def section_detail(request, section):
return render(request, 'editor/sections.html', {}) section = get_object_or_404(Section, pk=section)
return render(request, 'editor/section.html', {
'sections': Section.objects.all(),
'section': section,
'section_url': 'editor.section',
})
def list_mapitemtypes(request, section): def list_mapitemtypes(request, section):