Skip to content

Commit

Permalink
Avoid TypeError when remove used style (#829)
Browse files Browse the repository at this point in the history
* Avoid ``TypeError`` when remove used style

* Add upgrade step

* Fix changelog
  • Loading branch information
rodfersou authored and hvelarde committed Sep 18, 2018
1 parent e016cde commit 09d423f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ There's a frood who really knows where his towel is.
2.0b2 (unreleased)
^^^^^^^^^^^^^^^^^^

- Avoid ``TypeError`` when a style used on a tile was removed (fixes `#827 <https://github.com/collective/collective.cover/issues/827>`_).
[rodfersou]

- Avoid ``KeyError`` when tile schema has changed (refs. `brasil.gov.portal#524 <https://github.com/plonegovbr/brasil.gov.portal/issues/524>`_).
[hvelarde]

Expand Down
2 changes: 1 addition & 1 deletion src/collective/cover/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>21</version>
<version>22</version>
<dependencies>
<dependency>profile-collective.js.galleria:default</dependency>
<dependency>profile-collective.js.jqueryui:default</dependency>
Expand Down
3 changes: 3 additions & 0 deletions src/collective/cover/static/js/layout_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
if (key === 'tile-default') {
continue;
}
if (this.options[key] == null) {
continue;
}
this.options[key].selected = true;
}
this.update();
Expand Down
11 changes: 11 additions & 0 deletions src/collective/cover/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,14 @@ def test_registrations(self):
version = self.setup.getLastVersionForProfile(self.profile_id)[0]
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self._how_many_upgrades_to_do(), 1)


class Upgrade21to22TestCase(UpgradeTestCaseBase):

def setUp(self):
UpgradeTestCaseBase.setUp(self, u'21', u'22')

def test_registrations(self):
version = self.setup.getLastVersionForProfile(self.profile_id)[0]
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self._how_many_upgrades_to_do(), 1)
1 change: 1 addition & 0 deletions src/collective/cover/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<include package=".v19" />
<include package=".v20" />
<include package=".v21" />
<include package=".v22" />
</configure>
1 change: 1 addition & 0 deletions src/collective/cover/upgrades/v22/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
19 changes: 19 additions & 0 deletions src/collective/cover/upgrades/v22/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="collective.cover">

<genericsetup:upgradeSteps
source="21"
destination="22"
profile="collective.cover:default">

<genericsetup:upgradeStep
title="Cook JS resources"
handler="..cook_javascript_resources"
/>

</genericsetup:upgradeSteps>

</configure>

0 comments on commit 09d423f

Please sign in to comment.