Projet

Général

Profil

0003-backoffice-agenda-datasources-are-readonly-48282.patch

Lauréline Guérin, 16 février 2021 16:00

Télécharger (2,71 ko)

Voir les différences:

Subject: [PATCH 3/5] backoffice: agenda datasources are readonly (#48282)

 tests/admin_pages/test_datasource.py | 16 ++++++++++++++++
 wcs/admin/data_sources.py            |  5 ++++-
 2 files changed, 20 insertions(+), 1 deletion(-)
tests/admin_pages/test_datasource.py
375 375
    CardDef.wipe()
376 376

  
377 377

  
378
def test_data_sources_agenda_view(pub):
379
    create_superuser(pub)
380
    NamedDataSource.wipe()
381

  
382
    data_source = NamedDataSource(name='foobar')
383
    data_source.data_source = {'type': 'json', 'value': 'http://some.url'}
384
    data_source.external = 'agenda'
385
    data_source.store()
386

  
387
    app = login(get_app(pub))
388
    resp = app.get('/backoffice/settings/data-sources/%s/' % data_source.id)
389
    assert 'This data source is readonly.' in resp
390
    assert '/backoffice/settings/data-sources/%s/edit' % data_source.id not in resp
391
    assert '/backoffice/settings/data-sources/%s/delete' % data_source.id not in resp
392

  
393

  
378 394
def test_data_sources_edit(pub):
379 395
    create_superuser(pub)
380 396
    NamedDataSource.wipe()
wcs/admin/data_sources.py
233 233
            self.datasource = instance or NamedDataSource.get(component)
234 234
        except KeyError:
235 235
            raise errors.TraversalError()
236
        if self.datasource.external == 'agenda':
237
            self.datasource.readonly = True
236 238
        self.datasource_ui = NamedDataSourceUI(self.datasource)
237 239
        get_response().breadcrumb.append((component + '/', self.datasource.name))
238 240
        self.snapshots_dir = SnapshotsDirectory(self.datasource)
......
241 243
        r = TemplateIO(html=True)
242 244
        if self.datasource.is_readonly():
243 245
            r += htmltext('<div class="infonotice"><p>%s</p></div>') % _('This data source is readonly.')
244
            r += utils.snapshot_info_block(snapshot=self.datasource.snapshot_object)
246
            if hasattr(self.datasource, 'snapshot_object'):
247
                r += utils.snapshot_info_block(snapshot=self.datasource.snapshot_object)
245 248
        r += htmltext('<ul id="sidebar-actions">')
246 249
        if not self.datasource.is_readonly():
247 250
            r += htmltext('<li><a href="delete" rel="popup">%s</a></li>') % _('Delete')
248
-