From f09236c3ebfde2c52fb4117fde127cca2eb0d4fb Mon Sep 17 00:00:00 2001 From: idgserpro Date: Thu, 7 Apr 2016 14:45:44 -0300 Subject: [PATCH] Corrige 'Unexpected token' Passa a pegar o location.url sem o '?authenticator=' para evitar o erro Unexpected token < --- CHANGES.rst | 4 ++++ src/brasil/gov/tiles/static/tiles.js | 2 +- src/brasil/gov/tiles/tests/test_setup.py | 7 ++++++- src/brasil/gov/tiles/upgrades/__init__.py | 11 +++++++++++ src/brasil/gov/tiles/upgrades/v4000/configure.zcml | 6 ++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 23c39f73..4cbf097e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,10 @@ Alterações buildout.cfg e as versões mais novas no momento desse release de brasil.gov.tiles contém upgrades. +- Corrige erro "Unexpected token <" quando se utiliza collective.cover com + suporte a proteção CSRF. + [idgserpro] + - Corrige ícones dos tiles presentes em overrides já que nas versões de collective.cover >= 1.0a13 a estrutura dos recursos estáticos foi alterada. (closes `#140`). diff --git a/src/brasil/gov/tiles/static/tiles.js b/src/brasil/gov/tiles/static/tiles.js index 4cfbaddb..fb6dbaf5 100644 --- a/src/brasil/gov/tiles/static/tiles.js +++ b/src/brasil/gov/tiles/static/tiles.js @@ -362,7 +362,7 @@ $(function() { $.extend(self, { init: function(){ - Galleria.loadTheme(window.location.href.trim('/') + '/++resource++brasil.gov.tiles/galleria.classic.min.js'); + Galleria.loadTheme(window.location.protocol + '//' + window.location.host + location.pathname + '/++resource++brasil.gov.tiles/galleria.classic.min.js'); Galleria.configure({ _toggleInfo: false, // Set this to false if you want the caption to show always diff --git a/src/brasil/gov/tiles/tests/test_setup.py b/src/brasil/gov/tiles/tests/test_setup.py index c02a8653..e28fa872 100644 --- a/src/brasil/gov/tiles/tests/test_setup.py +++ b/src/brasil/gov/tiles/tests/test_setup.py @@ -99,10 +99,15 @@ def setUp(self): UpgradeTestCaseBase.setUp(self, u'3000', u'4000') self.profile_id = u'brasil.gov.tiles:default' + def test_upgrade_to_10_registrations(self): + # XXX: Como herdo de Upgrade9to10TestCase mas possuo dois upgradeSteps + # esse método dá erro, mas não preciso dele. + pass + def test_upgrade_to_4000_registrations(self): version = self.setup.getLastVersionForProfile(self.profile_id)[0] self.assertTrue(int(version) >= int(self.to_version)) - self.assertEqual(self._how_many_upgrades_to_do(), 1) + self.assertEqual(self._how_many_upgrades_to_do(), 2) def test_new_uuids_structure(self): title = u'Atualiza estrutura no banco do tipo Destaque' diff --git a/src/brasil/gov/tiles/upgrades/__init__.py b/src/brasil/gov/tiles/upgrades/__init__.py index 40a96afc..bbab97ff 100644 --- a/src/brasil/gov/tiles/upgrades/__init__.py +++ b/src/brasil/gov/tiles/upgrades/__init__.py @@ -1 +1,12 @@ # -*- coding: utf-8 -*- +from brasil.gov.tiles.config import PROJECTNAME +from plone import api + +import logging + +logger = logging.getLogger(PROJECTNAME) + + +def cook_javascript_resources(context): + api.portal.get_tool('portal_javascripts').cookResources() + logger.info('Javascript resources were cooked') diff --git a/src/brasil/gov/tiles/upgrades/v4000/configure.zcml b/src/brasil/gov/tiles/upgrades/v4000/configure.zcml index b76fbd8a..3cdb079a 100644 --- a/src/brasil/gov/tiles/upgrades/v4000/configure.zcml +++ b/src/brasil/gov/tiles/upgrades/v4000/configure.zcml @@ -14,6 +14,12 @@ handler=".handler.fix_persistentmap_to_dict_destaque" /> + +