From 1d6a254eb74c4e38943d6bb4f6fd1cf249092b27 Mon Sep 17 00:00:00 2001 From: idgserpro Date: Thu, 24 May 2018 09:59:24 -0300 Subject: [PATCH] Altera reg javascript do c.upload / c.p.calendar. (#474) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Altera reg javascript do c.upload / c.p.calendar. Altera ordem de registro de javascript do collective.upload e collective.portlet.calendar para corrigir alinhamento do título (refs. https://github.com/plonegovbr/brasil.gov.agenda/issues/82) * Code review. Ficar atento às várias opções disponibilizadas em https://docs.python.org/2/library/unittest.html#assert-methods A principal vantagem é a legibilidade: só de ler o assert você já entende a lógica ao invés de tentar interpretar a lógica interna que voltaria True para assertTrue anteriormente. Registros de css também não necessitam de 'insert-after' E 'insert-before' por ser redundante. --- CHANGES.rst | 3 ++ src/brasil/gov/portal/config.py | 2 ++ .../portal/profiles/default/cssregistry.xml | 4 +++ src/brasil/gov/portal/tests/test_setup.py | 8 +++++ src/brasil/gov/portal/tests/test_upgrades.py | 36 +++++++++++++++++++ .../gov/portal/upgrades/v10804/__init__.py | 8 +++++ .../gov/portal/upgrades/v10804/configure.zcml | 20 +++++++++++ .../v10804/profiles/default/cssregistry.xml | 7 ++++ 8 files changed, 88 insertions(+) create mode 100644 src/brasil/gov/portal/upgrades/v10804/profiles/default/cssregistry.xml diff --git a/CHANGES.rst b/CHANGES.rst index 1cf8e27e..6c19207b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ Changelog 1.5.2 (unreleased) ^^^^^^^^^^^^^^^^^^ +- Altera ordem de registro de javascript do collective.upload e collective.portlet.calendar para corrigir alinhamento do título (refs. `brasil.gov.agenda#82 `_). + [idgserpro] + - ${portal_url} e ${navigation_root_url} no metadata getRemoteUrl passam a ser transformados após atualização do IDG 1.5.1. Dessa forma, links criados em versões anteriores que davam erro de "Não encontrado" (com urls na barra do navegador como $%7Bportal_url%7D/acesso-a-sistemas) voltam a funcionar. (fecha `#463 `_). [idgserpro] diff --git a/src/brasil/gov/portal/config.py b/src/brasil/gov/portal/config.py index 9d869d53..538b57ea 100644 --- a/src/brasil/gov/portal/config.py +++ b/src/brasil/gov/portal/config.py @@ -72,6 +72,7 @@ 'brasil.gov.portal.upgrades.v10800', 'brasil.gov.portal.upgrades.v10802', 'brasil.gov.portal.upgrades.v10803', + 'brasil.gov.portal.upgrades.v10804', 'brasil.gov.portal.upgrades.v2000', 'brasil.gov.portal.upgrades.v3000', 'brasil.gov.portal.upgrades.v4000', @@ -139,6 +140,7 @@ 'brasil.gov.portal.upgrades.v10800:default', 'brasil.gov.portal.upgrades.v10802:default', 'brasil.gov.portal.upgrades.v10803:default', + 'brasil.gov.portal.upgrades.v10804:default', 'brasil.gov.portal.upgrades.v2000:default', 'brasil.gov.portal.upgrades.v3000:default', 'brasil.gov.portal.upgrades.v4000:default', diff --git a/src/brasil/gov/portal/profiles/default/cssregistry.xml b/src/brasil/gov/portal/profiles/default/cssregistry.xml index 57769ae0..fbf05e62 100644 --- a/src/brasil/gov/portal/profiles/default/cssregistry.xml +++ b/src/brasil/gov/portal/profiles/default/cssregistry.xml @@ -6,4 +6,8 @@ + diff --git a/src/brasil/gov/portal/tests/test_setup.py b/src/brasil/gov/portal/tests/test_setup.py index 7fef87fd..2e94324b 100644 --- a/src/brasil/gov/portal/tests/test_setup.py +++ b/src/brasil/gov/portal/tests/test_setup.py @@ -646,6 +646,14 @@ def test_to10802_execution(self): selectable_views_property = self.portal.getProperty('selectable_views') self.assertTupleEqual(selectable_views_property, SELECTABLE_VIEWS) + def test_css_upload_before_css_portlet_calendar_first_install(self): + portal_css = api.portal.get_tool('portal_css') + upload_css_id = '++resource++collective.upload/upload.css' + portlet_calendar_css_id = '++resource++calendar_styles/calendar.css' + upload_pos = portal_css.getResourcePosition(upload_css_id) + calendar_pos = portal_css.getResourcePosition(portlet_calendar_css_id) + self.assertLess(upload_pos, calendar_pos) + def test_upgrade_step_variavel_hidden_profiles_deps_brasil_gov_portal(self): # NOQA """ Testa se todos os upgradeSteps de brasil.gov.portal que possuem profile diff --git a/src/brasil/gov/portal/tests/test_upgrades.py b/src/brasil/gov/portal/tests/test_upgrades.py index ae6c6483..5aa9e5b2 100644 --- a/src/brasil/gov/portal/tests/test_upgrades.py +++ b/src/brasil/gov/portal/tests/test_upgrades.py @@ -154,3 +154,39 @@ def test_tinymce_ancora_links_internos(self): portal_tinymce.anchor_selector.split(','), is_10803_anchor_selector, ) + + +class To10804TestCase(UpgradeBaseTestCase): + + from_ = '10803' + to_ = '10804' + + def test_profile_version(self): + version = self.setup.getLastVersionForProfile(self.profile_id)[0] + self.assertEqual(version, self.from_) + + def test_registered_steps(self): + steps = len(self.setup.listUpgrades(self.profile_id)[0]) + self.assertEqual(steps, 3) + + def test_css_upload_before_css_portlet_calendar(self): + title = u'Altera ordem de arquivos css' + step = self._get_upgrade_step_by_title(title) + self.assertIsNotNone(step) + + portal_css = api.portal.get_tool('portal_css') + upload_css_id = '++resource++collective.upload/upload.css' + portlet_calendar_css_id = '++resource++calendar_styles/calendar.css' + + # Simula situação incorreta: css do upload depois do calendar. + portal_css.moveResourceToTop(portlet_calendar_css_id) + portal_css.moveResourceToBottom(upload_css_id) + upload_pos = portal_css.getResourcePosition(upload_css_id) + calendar_pos = portal_css.getResourcePosition(portlet_calendar_css_id) + self.assertGreater(upload_pos, calendar_pos) + + # execute upgrade step and verify changes were applied + self._do_upgrade(step) + upload_pos = portal_css.getResourcePosition(upload_css_id) + calendar_pos = portal_css.getResourcePosition(portlet_calendar_css_id) + self.assertLess(upload_pos, calendar_pos) diff --git a/src/brasil/gov/portal/upgrades/v10804/__init__.py b/src/brasil/gov/portal/upgrades/v10804/__init__.py index 258384fd..24a8fe46 100644 --- a/src/brasil/gov/portal/upgrades/v10804/__init__.py +++ b/src/brasil/gov/portal/upgrades/v10804/__init__.py @@ -2,6 +2,7 @@ from brasil.gov.portal.logger import logger from collective.nitf.upgrades.v2000 import get_valid_objects from plone import api +from plone.app.upgrade.utils import loadMigrationProfile import transaction @@ -26,3 +27,10 @@ def reindex_get_remote_url_link(setup_tool): transaction.commit() logger.info('Done.') + + +def apply_profile(setup_tool): + """Atualiza profile para versao 10804""" + profile = 'profile-brasil.gov.portal.upgrades.v10804:default' + loadMigrationProfile(setup_tool, profile) + logger.info('Atualizado para versao 10804') diff --git a/src/brasil/gov/portal/upgrades/v10804/configure.zcml b/src/brasil/gov/portal/upgrades/v10804/configure.zcml index 73edb85b..8c10534b 100644 --- a/src/brasil/gov/portal/upgrades/v10804/configure.zcml +++ b/src/brasil/gov/portal/upgrades/v10804/configure.zcml @@ -4,6 +4,14 @@ xmlns:genericsetup="http://namespaces.zope.org/genericsetup" i18n_domain="brasil.gov.portal"> + + + + + + diff --git a/src/brasil/gov/portal/upgrades/v10804/profiles/default/cssregistry.xml b/src/brasil/gov/portal/upgrades/v10804/profiles/default/cssregistry.xml new file mode 100644 index 00000000..0d55e42b --- /dev/null +++ b/src/brasil/gov/portal/upgrades/v10804/profiles/default/cssregistry.xml @@ -0,0 +1,7 @@ + + + +