manager: redirect to new cell after cell duplicate (#58186)
This commit is contained in:
parent
d983ecd850
commit
d41302e20b
|
@ -699,10 +699,12 @@ class PageDuplicateCellView(ManagedPageMixin, RedirectView):
|
|||
cell = CellBase.get_cell(cell_reference, page_id=page_pk)
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404()
|
||||
cell.duplicate(reset_slug=True, set_order=True)
|
||||
new_cell = cell.duplicate(reset_slug=True, set_order=True)
|
||||
PageSnapshot.take(cell.page, request=self.request, comment=_('duplicated cell "%s"') % cell)
|
||||
messages.info(self.request, _('Cell %s has been duplicated.') % cell)
|
||||
return reverse('combo-manager-page-view', kwargs={'pk': page_pk}) + '#cell-' + cell.get_reference()
|
||||
return (
|
||||
reverse('combo-manager-page-view', kwargs={'pk': page_pk}) + '#cell-' + new_cell.get_reference()
|
||||
)
|
||||
|
||||
|
||||
page_duplicate_cell = PageDuplicateCellView.as_view()
|
||||
|
|
|
@ -541,7 +541,7 @@ def test_page_edit_picture(app, admin_user):
|
|||
resp = resp.click(href='.*/remove-picture/')
|
||||
resp = resp.follow()
|
||||
assert '<h2>Page - One</h2>' in resp.text
|
||||
assert not '<img' in resp.text
|
||||
assert '<img' not in resp.text
|
||||
|
||||
resp = resp.click(href='.*/picture/')
|
||||
resp.form['picture'] = Upload('black.svg', b'<svg xmlns="http://www.w3.org/2000/svg"/>', 'image/svg+xml')
|
||||
|
@ -1210,7 +1210,7 @@ def test_add_all_basic_cell_types(app, admin_user):
|
|||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
for option in resp.html.find_all('option'):
|
||||
if not '/data_' in option.get('data-add-url'):
|
||||
if '/data_' not in option.get('data-add-url'):
|
||||
continue
|
||||
resp = app.get(option.get('data-add-url'))
|
||||
resp = resp.follow()
|
||||
|
@ -1281,10 +1281,12 @@ def test_duplicate_cell(app, admin_user):
|
|||
cell = TextCell.objects.create(page=page, placeholder='content', text='Foobar', order=0, slug='foobar')
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.pk)
|
||||
resp = resp.click(href='/data_textcell-%s/duplicate' % cell.pk).follow()
|
||||
assert 'Cell %s has been duplicated.' % cell in resp.text
|
||||
resp = resp.click(href='/data_textcell-%s/duplicate' % cell.pk)
|
||||
assert TextCell.objects.count() == 2
|
||||
new_cell = TextCell.objects.latest('pk')
|
||||
assert resp.location.endswith('/manage/pages/%s/#cell-%s' % (page.pk, new_cell.get_reference()))
|
||||
resp = resp.follow()
|
||||
assert 'Cell %s has been duplicated.' % cell in resp.text
|
||||
assert new_cell.slug == ''
|
||||
assert new_cell.order == 1
|
||||
assert new_cell.page == page
|
||||
|
@ -1375,7 +1377,7 @@ def test_edit_cell_options(app, admin_user):
|
|||
resp.form['cdata_textcell-%s-slug' % cell.id] = ''
|
||||
resp = resp.form.submit('submit')
|
||||
assert TextCell.objects.get(id=cell.id).slug == ''
|
||||
assert not 'SLUG' in app.get('/manage/pages/%s/' % page.id)
|
||||
assert 'SLUG' not in app.get('/manage/pages/%s/' % page.id)
|
||||
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
resp = resp.click(href='/data_textcell-%s/options' % cell.id)
|
||||
|
@ -1500,7 +1502,7 @@ def test_edit_config_json_cell(app, admin_user):
|
|||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
options = [x.text for x in resp.html.find_all('option')]
|
||||
assert not 'Foobar' in options
|
||||
assert 'Foobar' not in options
|
||||
|
||||
templates_settings = [settings.TEMPLATES[0].copy()]
|
||||
templates_settings[0]['DIRS'] = ['%s/templates-1' % os.path.abspath(os.path.dirname(__file__))]
|
||||
|
|
Loading…
Reference in New Issue