add control panel index

This commit is contained in:
Laura Klünder 2017-12-08 15:21:33 +01:00
parent 65917be3e0
commit 01b703fad2
9 changed files with 43 additions and 5 deletions

View file

@ -0,0 +1,13 @@
{% extends 'site/base.html' %}
{% load i18n %}
{% block title %}{% trans 'c3nav control panel' %}{% endblock %}
{% block header_title %}{% trans 'c3nav control panel' %}{% endblock %}
{% block header_title_url %}{% url 'control.index' %}{% endblock %}
{% block content %}
<main>
{% block subcontent %}
{% endblock %}
</main>
{% endblock %}

View file

@ -0,0 +1,8 @@
{% extends 'control/base.html' %}
{% load i18n %}
{% block subcontent %}
<h2>{% trans 'Overview' %}</h2>
<p>{% trans 'Welcome to the c3nav control panel.' %}</p>
{% endblock %}

View file

@ -1,6 +1,7 @@
# from django.conf.urls import url
from django.conf.urls import url
from c3nav.control.views import main_index
urlpatterns = [
# url(r'^register$', register_view, name='control.index'),
url(r'^$', main_index, name='control.index'),
]

View file

@ -0,0 +1,5 @@
from django.shortcuts import render
def main_index(request):
return render(request, 'control/index.html', {})

View file

@ -0,0 +1,7 @@
from c3nav.mapdata.utils.user import get_user_data_lazy
def user_data(request):
return {
'user_data': get_user_data_lazy(request)
}

View file

@ -1,3 +1,4 @@
from django.utils.functional import lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
@ -24,3 +25,6 @@ def get_user_data(request):
if request.user.is_authenticated:
result['title'] = request.user.username
return result
get_user_data_lazy = lazy(get_user_data, dict)

View file

@ -268,6 +268,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'c3nav.mapdata.context_processors.user_data',
],
'loaders': template_loaders
},

View file

@ -6,7 +6,7 @@
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>c3nav</title>
<title>{% block title %}c3nav{% endblock %}</title>
{% compress css %}
<link href="{% static 'fonts/fonts.css' %}" rel="stylesheet">
<link href="{% static 'normalize/normalize.css' %}" rel="stylesheet">
@ -19,7 +19,7 @@
<body>
{% if not embed %}
<header>
<h1><a href="/">c3nav</a></h1>
<h1><a href="{% block header_title_url %}/{% endblock %}">{% block header_title %}c3nav{% endblock %}</a></h1>
<a href="/account/" id="user">
<span>{{ user_data.title }}</span>
<small>{% if user_data.subtitle %}{{ user_data.subtitle }}{% endif %}</small>

View file

@ -83,7 +83,6 @@ def map_index(request, mode=None, slug=None, slug2=None, details=None,
'levels': json.dumps(tuple((level.pk, level.short_label) for level in levels.values()), separators=(',', ':')),
'state': json.dumps(state, separators=(',', ':'), cls=DjangoJSONEncoder),
'tile_cache_server': settings.TILE_CACHE_SERVER,
'user_data': get_user_data(request),
'embed': bool(embed),
}
response = render(request, 'site/map.html', ctx)