From b38486110c8d950ccb304608f6323b2fb0fdbc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 18 Nov 2015 13:58:05 +0100 Subject: [PATCH] admin: fix creation of non-first named data source (#9020) --- tests/test_admin_pages.py | 13 +++++++++++++ wcs/admin/data_sources.py | 2 ++ 2 files changed, 15 insertions(+) diff --git a/tests/test_admin_pages.py b/tests/test_admin_pages.py index 89dc68e..6c690c0 100644 --- a/tests/test_admin_pages.py +++ b/tests/test_admin_pages.py @@ -2306,6 +2306,19 @@ def test_data_sources_new(pub): assert NamedDataSource.get(1).name == 'a new data source' assert NamedDataSource.get(1).description == 'description of the data source' + # add a second one + resp = app.get('/backoffice/settings/data-sources/') + resp = resp.click('New Data Source') + resp.forms[0]['name'] = 'an other data source' + resp.forms[0]['description'] = 'description of the data source' + resp.forms[0]['data_source$type'] = 'Formula (Python)' + resp = resp.forms[0].submit('data_source$apply') + resp.forms[0]['data_source$value'] = repr( + [{'id': '1', 'text': 'un'}, {'id': '2', 'text': 'deux'}]) + resp = resp.forms[0].submit('submit') + + assert NamedDataSource.count() == 2 + def test_data_sources_edit(pub): create_superuser(pub) NamedDataSource.wipe() diff --git a/wcs/admin/data_sources.py b/wcs/admin/data_sources.py index 5994777..232e4ff 100644 --- a/wcs/admin/data_sources.py +++ b/wcs/admin/data_sources.py @@ -56,6 +56,8 @@ class NamedDataSourceUI(object): name = form.get_widget('name').parse() if self.datasource.slug: slug = form.get_widget('slug').parse() + else: + slug = None for nds in NamedDataSource.select(): if nds.id == self.datasource.id: -- 2.6.2