wcs: hide general tab for categories cell if no wcs_site selection (#66310)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Lauréline Guérin 2022-06-16 11:33:03 +02:00
parent 17fb7f22e6
commit 9b5274a663
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 19 additions and 3 deletions

View File

@ -397,9 +397,10 @@ class WcsDataBaseCell(CellBase, WcsBlurpMixin):
return {'wcs_site': Select(choices=combo_wcs_sites)}
def get_default_form_class(self):
return model_forms.modelform_factory(
self.__class__, fields=self.get_form_fields(), widgets=self.get_form_widgets()
)
fields = self.get_form_fields()
if not fields:
return None
return model_forms.modelform_factory(self.__class__, fields=fields, widgets=self.get_form_widgets())
def get_cell_extra_context(self, context):
extra_context = super().get_cell_extra_context(context)

View File

@ -616,6 +616,21 @@ def test_category_cell_validity(mock_send):
assert validity_info.invalid_since is not None
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_manager_categories_cell(mock_send, settings, app, admin_user):
page = Page.objects.create(title='xxx', slug='test', template_name='standard')
CategoriesCell.objects.create(page=page, placeholder='content', order=0)
app = login(app)
resp = app.get('/manage/pages/%s/' % page.pk)
assert resp.pyquery('[data-tab-slug="general"] select[name$="wcs_site"]')
default = settings.KNOWN_SERVICES['wcs']['default']
settings.KNOWN_SERVICES = {'wcs': {'default': default}}
resp = app.get('/manage/pages/%s/' % page.pk)
assert not resp.pyquery('[data-tab-slug="general"]')
@mock.patch('requests.Session.send', side_effect=mocked_requests_send)
def test_categories_cell_check_validity(mock_send):
page = Page.objects.create(title='xxx', slug='test', template_name='standard')