public: display a welcome message on empty sites (#7213)

This commit is contained in:
Frédéric Péters 2015-05-15 16:56:58 +02:00
parent 8bbd58a7ab
commit aa40823826
3 changed files with 74 additions and 2 deletions

View File

@ -0,0 +1,64 @@
{% load i18n %}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
body {
margin: auto;
text-align: center;
}
#content:after {
position: absolute;
text-align: center;
margin: auto;
content: "↑↑ ↓↓ ←→ ←→ B A";
font-family: sans-serif;
font-weight: bold;
font-size: 20vh;
display: block;
width: 4em;
padding-left: 0.3em;
color: rgba(0, 0, 0, 0.03);
top: 0;
}
#content {
position: relative;
z-index: 10;
width: 50%;
max-width: 30em;
margin: 6em auto;
padding: 1em;
text-align: left;
height: 100%;
font-size: 200%;
}
#content #goto {
padding-left: 1em;
}
#content a {
color: inherit;
}
</style>
</head>
<body>
<div id="content">
<h1>{% trans 'Welcome!' %}</h1>
{% blocktrans %}
<p>
Your installation of Combo was successful and you can now play with it
to your heart's content. It is currently empty, your first move should
probably be to head to the management interface to add some pages.
</p>
{% endblocktrans %}
<p id="goto">
<a href="{% url 'combo-manager-homepage' %}">{% url 'combo-manager-homepage' %}</a>
</p>
</div>
</body>
</html>

View File

@ -141,6 +141,10 @@ def skeleton(request):
return render(request, template_name, ctx)
def empty_site(request):
return render(request, 'combo/empty_site.html', {})
def page(request):
url = request.path_info
parts = [x for x in request.path_info.strip('/').split('/') if x]
@ -151,7 +155,10 @@ def page(request):
except Page.DoesNotExist:
if not url.endswith('/') and settings.APPEND_SLASH:
return HttpResponsePermanentRedirect(url + '/')
raise Http404()
if Page.objects.count() == 0 and parts == ['index']:
return empty_site(request)
else:
raise Http404()
for i, page in enumerate(pages[1:]):
if page.parent_id != pages[i].id:

View File

@ -12,7 +12,8 @@ from test_manager import admin_user, login
def test_missing_index():
Page.objects.all().delete()
app = TestApp(application)
resp = app.get('/', status=404)
resp = app.get('/', status=200)
assert 'Welcome' in resp.body
def test_index():
Page.objects.all().delete()