diff --git a/tests/admin_pages/test_datasource.py b/tests/admin_pages/test_datasource.py index c9535c65d..43a00561c 100644 --- a/tests/admin_pages/test_datasource.py +++ b/tests/admin_pages/test_datasource.py @@ -375,6 +375,22 @@ def test_data_sources_view(pub): CardDef.wipe() +def test_data_sources_agenda_view(pub): + create_superuser(pub) + NamedDataSource.wipe() + + data_source = NamedDataSource(name='foobar') + data_source.data_source = {'type': 'json', 'value': 'http://some.url'} + data_source.external = 'agenda' + data_source.store() + + app = login(get_app(pub)) + resp = app.get('/backoffice/settings/data-sources/%s/' % data_source.id) + assert 'This data source is readonly.' in resp + assert '/backoffice/settings/data-sources/%s/edit' % data_source.id not in resp + assert '/backoffice/settings/data-sources/%s/delete' % data_source.id not in resp + + 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 a2e6eb237..5046f3975 100644 --- a/wcs/admin/data_sources.py +++ b/wcs/admin/data_sources.py @@ -233,6 +233,8 @@ class NamedDataSourcePage(Directory): self.datasource = instance or NamedDataSource.get(component) except KeyError: raise errors.TraversalError() + if self.datasource.external == 'agenda': + self.datasource.readonly = True self.datasource_ui = NamedDataSourceUI(self.datasource) get_response().breadcrumb.append((component + '/', self.datasource.name)) self.snapshots_dir = SnapshotsDirectory(self.datasource) @@ -241,7 +243,8 @@ class NamedDataSourcePage(Directory): r = TemplateIO(html=True) if self.datasource.is_readonly(): r += htmltext('

%s

') % _('This data source is readonly.') - r += utils.snapshot_info_block(snapshot=self.datasource.snapshot_object) + if hasattr(self.datasource, 'snapshot_object'): + r += utils.snapshot_info_block(snapshot=self.datasource.snapshot_object) r += htmltext('