manager: allow dynamic fields in cell edit form (#49175)
This commit is contained in:
parent
e56b1e4b97
commit
1a629d57c7
|
@ -546,6 +546,7 @@ class PageEditCellView(UpdateView):
|
|||
def form_valid(self, form):
|
||||
if self.request.is_ajax():
|
||||
self.object = form.save()
|
||||
form = self.get_form_class()(instance=self.object, prefix=self.get_prefix())
|
||||
response = self.form_invalid(form) # avoid redirection
|
||||
else:
|
||||
response = super(PageEditCellView, self).form_valid(form)
|
||||
|
|
|
@ -996,6 +996,20 @@ def test_chartng_cell_manager_new_api(app, admin_user, new_api_statistics):
|
|||
assert cell.filter_params == {}
|
||||
|
||||
|
||||
@with_httmock(new_api_mock)
|
||||
def test_chartng_cell_manager_new_api_dynamic_fields(app, admin_user, new_api_statistics):
|
||||
page = Page.objects.create(title='One', slug='index')
|
||||
cell = ChartNgCell.objects.create(page=page, order=1, placeholder='content')
|
||||
statistic = Statistic.objects.get(slug='one-serie')
|
||||
|
||||
app = login(app)
|
||||
resp = app.get('/manage/pages/%s/' % page.id)
|
||||
field_prefix = 'cdataviz_chartngcell-%s-' % cell.id
|
||||
resp.form[field_prefix + 'statistic'] = statistic.pk
|
||||
resp = app.post(resp.form.action, params=resp.form.submit_fields(), xhr=True)
|
||||
assert 'time_interval' in resp.text
|
||||
|
||||
|
||||
@with_httmock(bijoe_mock)
|
||||
def test_table_cell(app, admin_user, statistics):
|
||||
page = Page(title='One', slug='index')
|
||||
|
@ -1168,8 +1182,8 @@ def test_chartng_cell_new_api_filter_params(new_api_statistics, nocache):
|
|||
|
||||
chart = cell.get_chart()
|
||||
request = new_api_mock.call['requests'][0]
|
||||
assert 'time_interval' not in request.url
|
||||
assert 'ou' not in request.url
|
||||
assert 'time_interval=' not in request.url
|
||||
assert 'ou=' not in request.url
|
||||
|
||||
cell.filter_params = {'time_interval': 'day', 'ou': 'default'}
|
||||
cell.save()
|
||||
|
|
Loading…
Reference in New Issue