diff --git a/combo/public/templates/combo/empty_site.html b/combo/public/templates/combo/empty_site.html new file mode 100644 index 00000000..8b93f87b --- /dev/null +++ b/combo/public/templates/combo/empty_site.html @@ -0,0 +1,64 @@ +{% load i18n %} + + + + + + + +
+

{% trans 'Welcome!' %}

+ {% blocktrans %} +

+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. +

+ {% endblocktrans %} +

+→ {% url 'combo-manager-homepage' %} +

+
+ + + diff --git a/combo/public/views.py b/combo/public/views.py index 366adb55..b3c013e7 100644 --- a/combo/public/views.py +++ b/combo/public/views.py @@ -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: diff --git a/tests/test_public.py b/tests/test_public.py index 86f6fc5d..390f998e 100644 --- a/tests/test_public.py +++ b/tests/test_public.py @@ -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()