Skip to content

Commit

Permalink
Merge pull request #515 from tiberiuichim/simple_404_page
Browse files Browse the repository at this point in the history
Simplify 404 http error view template; Make nav-bar and editor-bar slots same between view/master.pt and edit/master.pt
  • Loading branch information
tiberiuichim committed Nov 29, 2016
2 parents a098d2f + 101283d commit 22e92c7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Change History
a defined add_view. This avoids a hard crash with, for example, a content
type derived from Content that has no add_view defined.

- Added ``nav-bar`` slot to ``edit/master.pt``, ``edit-bar`` and ``nav-bar``
slots to ``view/master.pt``

- Bugfix: Simplify 404 page, no longer crash when authenticated

- Change: simplify `kotti.util.LinkBase.selected()`: use request.view_name
instead of deriving the view name from request.url. Also, consider the View
editor bar entry as selected even when the url doesn't end with a slash '/'
Expand Down
11 changes: 8 additions & 3 deletions kotti/templates/edit/master.pt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@
</head>

<body class="view-${request.view_name or 'default'} ${api.body_css_class} logged-in">
<nav tal:replace="api.render_template('kotti:templates/view/nav.pt')" />
<metal:editorbar define-slot="editor-bar" tal:condition="request.user is not None"
tal:replace="api.render_template('kotti:templates/editor-bar.pt')" />

<nav tal:omit-tag="" metal:define-slot="nav-bar">
<nav tal:replace="api.render_template('kotti:templates/view/nav.pt')" ></nav>
</nav>
<editbar tal:omit-tag="" metal:define-slot="editor-bar">
<div tal:condition="request.user is not None"
tal:replace="api.render_template('kotti:templates/editor-bar.pt')" ></div>
</editbar>

<div class="container">
<div class="row">
Expand Down
20 changes: 20 additions & 0 deletions kotti/templates/http-errors/notfound.pt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
<html i18n:domain="Kotti"
metal:use-macro="api.macro('kotti:templates/view/master.pt')">

<div metal:fill-slot="nav-bar">
<nav class="navbar navbar-static-top navbar-inverse"
role="navigation"
id="navbar-view">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-view-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="${request.application_url}/">
${api.site_title}
</a>
</div>
</div>
</nav>
</div>

<div metal:fill-slot="content" class="notfound">
<h1 i18n:translate="">Not Found</h1>
<p i18n:translate="">The resource could not be found</p>
Expand Down
11 changes: 8 additions & 3 deletions kotti/templates/view/master.pt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@
<body class="${request.user is not None and 'logged-in'}
view-${request.view_name or 'default'}
${api.body_css_class}">
<nav tal:replace="api.render_template('kotti:templates/view/nav.pt')" />
<div tal:condition="request.user is not None and has_location_context"
tal:replace="api.render_template('kotti:templates/editor-bar.pt')" />

<nav tal:omit-tag="" metal:define-slot="nav-bar">
<nav tal:replace="api.render_template('kotti:templates/view/nav.pt')" />
</nav>
<editbar tal:omit-tag="" metal:define-slot="editor-bar">
<div tal:condition="request.user is not None and has_location_context"
tal:replace="api.render_template('kotti:templates/editor-bar.pt')" />
</editbar>

<div class="container">
<div tal:replace="api.render_template('kotti:templates/edit/breadcrumbs.pt')" />
Expand Down
6 changes: 6 additions & 0 deletions kotti/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ def test_login(self, webtest):
resp = form.submit('submit').maybe_follow()
assert "Welcome, Administrator" in resp.body

@pytest.mark.user('admin')
def test_exception_views(self, webtest):
app = webtest.app
resp = app.get('/this-does-not-exist', status=404)
assert "<h1>Not Found</h1>" in resp.body

@pytest.mark.user('admin')
def test_content_management(self, webtest):

Expand Down

0 comments on commit 22e92c7

Please sign in to comment.