Skip to content

Commit

Permalink
Altera reg javascript do c.upload / c.p.calendar. (#474)
Browse files Browse the repository at this point in the history
* 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. plonegovbr/brasil.gov.agenda#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.
  • Loading branch information
idgserpro authored and hvelarde committed May 24, 2018
1 parent dc3cc2a commit 1d6a254
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/plonegovbr/brasil.gov.agenda/issues/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 <https://github.com/plonegovbr/brasil.gov.portal/issues/463>`_).
[idgserpro]

Expand Down
2 changes: 2 additions & 0 deletions src/brasil/gov/portal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions src/brasil/gov/portal/profiles/default/cssregistry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<stylesheet title="" cacheable="True" compression="safe" cookable="True"
enabled="1" expression="" id="++resource++brasil.gov.portal/css/main-print.css" media="print"
rel="stylesheet" rendering="link" insert-after="++resource++brasil.gov.portal/css/main.css"/>
<stylesheet title="" cacheable="True" compression="none" cookable="True"
enabled="1" expression="" id="++resource++collective.upload/upload.css" media="screen"
insert-before="++resource++calendar_styles/calendar.css"
rel="stylesheet" authenticated="True" rendering="link" />
</object>
8 changes: 8 additions & 0 deletions src/brasil/gov/portal/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions src/brasil/gov/portal/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions src/brasil/gov/portal/upgrades/v10804/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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')
20 changes: 20 additions & 0 deletions src/brasil/gov/portal/upgrades/v10804/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="brasil.gov.portal">

<genericsetup:registerProfile
name="default"
title="Identidade Digital: Versão 10804"
directory="profiles/default"
description="Configurações da Versão 10804 do portal"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:upgradeSteps
source="10803"
destination="10804"
Expand All @@ -15,6 +23,18 @@
handler=".reindex_get_remote_url_link"
/>

<genericsetup:upgradeStep
title="Altera ordem de arquivos css"
description="Altera ordem de registro de javascript do collective.upload e collective.portlet.calendar para corrigir alinhamento do título."
handler=".apply_profile"
/>

<genericsetup:upgradeStep
title="Cook Resources"
description="Atualiza estilos da configuração do brasil.gov.portal."
handler="brasil.gov.portal.upgrades.csscookresources"
/>

</genericsetup:upgradeSteps>

</configure>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<object name="portal_css" meta_type="Stylesheets Registry" purge="False">
<stylesheet title="" cacheable="True" compression="none" cookable="True"
enabled="1" expression="" id="++resource++collective.upload/upload.css" media="screen"
insert-before="++resource++calendar_styles/calendar.css"
rel="stylesheet" authenticated="True" rendering="link" />
</object>

0 comments on commit 1d6a254

Please sign in to comment.