cells: take a snapshot when a link is added to a list of links cell

This commit is contained in:
Lauréline Guérin 2020-02-06 16:57:12 +01:00
parent eda9d548a0
commit 06417b1ff9
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 5 additions and 0 deletions

View File

@ -631,6 +631,7 @@ class PageListCellAddLinkView(CreateView):
form.instance.order = max(orders)+1
else:
form.instance.order = 1
PageSnapshot.take(self.cell.page, request=self.request, comment=_('changed cell "%s"') % self.cell)
return super(PageListCellAddLinkView, self).form_valid(form)
def get_success_url(self):

View File

@ -1515,6 +1515,7 @@ def test_add_edit_delete_list_link_item(app, admin_user):
cell = LinkListCell.objects.create(order=0, placeholder='content', page=page)
app = login(app)
resp = app.get('/manage/pages/%s/' % page.pk)
assert PageSnapshot.objects.count() == 0
resp = resp.click(href='.*/add-link/link$')
resp.forms[0]['title'] = 'Hello world'
@ -1528,6 +1529,7 @@ def test_add_edit_delete_list_link_item(app, admin_user):
assert item.url == 'http://example.com'
assert item.page == page
assert item.placeholder == cell.link_placeholder
assert PageSnapshot.objects.count() == 1
resp = resp.follow()
resp = resp.click(href='.*/link/%s/$' % item.get_reference())
@ -1540,6 +1542,7 @@ def test_add_edit_delete_list_link_item(app, admin_user):
item.refresh_from_db()
assert item.title == 'Hello world 2'
assert item.url == 'http://example2.com'
assert PageSnapshot.objects.count() == 2
resp = resp.follow()
resp = resp.click(href='.*/link/%s/delete' % item.get_reference())
@ -1547,6 +1550,7 @@ def test_add_edit_delete_list_link_item(app, admin_user):
assert resp.status_int == 302
assert resp.location.endswith('/manage/pages/%s/#cell-%s' % (page.pk, cell.get_reference()))
assert LinkCell.objects.count() == 0
assert PageSnapshot.objects.count() == 3
def test_edit_link_list_order(app, admin_user):