history: check if page exists (#41246)

This commit is contained in:
Lauréline Guérin 2020-04-20 16:18:27 +02:00
parent 47e1b31b42
commit f8c6af9ed8
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 5 additions and 1 deletions

View File

@ -402,9 +402,10 @@ class PageHistoryView(ListView):
paginate_by = 20
def get_queryset(self):
self.page = Page.objects.get(id=self.kwargs['pk'])
self.page = get_object_or_404(Page, pk=self.kwargs['pk'])
return self.page.pagesnapshot_set.all()
page_history = PageHistoryView.as_view()

View File

@ -1614,6 +1614,9 @@ def test_page_versionning(app, admin_user):
assert TextCell.objects.count() == 3
assert JsonCell.objects.count() == 0
# page does not exists
app.get('/manage/pages/0/history', status=404)
def test_view_old_snapshot(app, admin_user):
page = Page.objects.create(title='One', slug='one')