Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove registro de recursos estáticos do swiper registrados por engano #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/brasil/gov/tiles/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,18 @@ def test_deprecate_resource_registries(self):
from brasil.gov.tiles.upgrades.v4101 import CSS

js_tool = api.portal.get_tool('portal_javascripts')
js_tool.registerResource(id=JS)
self.assertIn(JS, js_tool.getResourceIds())
for js in JS:
js_tool.registerResource(id=js)
self.assertIn(js, js_tool.getResourceIds())

css_tool = api.portal.get_tool('portal_css')
css_tool.registerResource(id=CSS)
self.assertIn(CSS, css_tool.getResourceIds())
for css in CSS:
css_tool.registerResource(id=css)
self.assertIn(css, css_tool.getResourceIds())

# run the upgrade step to validate the update
self._do_upgrade(step)
self.assertNotIn(JS, js_tool.getResourceIds())
self.assertNotIn(CSS, css_tool.getResourceIds())
for js in JS:
self.assertNotIn(js, js_tool.getResourceIds())
for css in CSS:
self.assertNotIn(css, css_tool.getResourceIds())
24 changes: 16 additions & 8 deletions src/brasil/gov/tiles/upgrades/v4101/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@
from plone import api


JS = '++resource++brasil.gov.tiles/brasilgovtiles.js'
CSS = '++resource++brasil.gov.tiles/brasilgovtiles.css'
JS = [
'++resource++brasil.gov.tiles/brasilgovtiles.js',
'++resource++brasil.gov.tiles/vendor/swiper.min.js',
]
CSS = [
'++resource++brasil.gov.tiles/brasilgovtiles.css',
'++resource++brasil.gov.tiles/vendor/swiper.min.css',
]


def deprecate_resource_registries(setup_tool):
"""Deprecate resource registries."""
js_tool = api.portal.get_tool('portal_javascripts')
if JS in js_tool.getResourceIds():
js_tool.unregisterResource(id=JS)
assert JS not in js_tool.getResourceIds() # nosec
for js in JS:
if js in js_tool.getResourceIds():
js_tool.unregisterResource(id=js)
assert js not in js_tool.getResourceIds() # nosec

css_tool = api.portal.get_tool('portal_css')
if CSS in css_tool.getResourceIds():
css_tool.unregisterResource(id=CSS)
assert CSS not in css_tool.getResourceIds() # nosec
for css in CSS:
if css in css_tool.getResourceIds():
css_tool.unregisterResource(id=css)
assert css not in css_tool.getResourceIds() # nosec

logger.info('Static resources successfully removed from registries')