|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# This file is part of SENAITE.CORE. |
| 4 | +# |
| 5 | +# SENAITE.CORE is free software: you can redistribute it and/or modify it under |
| 6 | +# the terms of the GNU General Public License as published by the Free Software |
| 7 | +# Foundation, version 2. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 12 | +# details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License along with |
| 15 | +# this program; if not, write to the Free Software Foundation, Inc., 51 |
| 16 | +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | +# |
| 18 | +# Copyright 2018-2021 by it's authors. |
| 19 | +# Some rights reserved, see README and LICENSE. |
| 20 | + |
| 21 | +from senaite.core import logger |
| 22 | +from senaite.core.config import PROJECTNAME as product |
| 23 | +from senaite.core.upgrade import upgradestep |
| 24 | +from senaite.core.upgrade.utils import UpgradeUtils |
| 25 | + |
| 26 | +version = "2.2.0" # Remember version number in metadata.xml and setup.py |
| 27 | +profile = "profile-{0}:default".format(product) |
| 28 | + |
| 29 | + |
| 30 | +@upgradestep(product, version) |
| 31 | +def upgrade(tool): |
| 32 | + portal = tool.aq_inner.aq_parent |
| 33 | + setup = portal.portal_setup # noqa |
| 34 | + ut = UpgradeUtils(portal) |
| 35 | + ver_from = ut.getInstalledVersion(product) |
| 36 | + |
| 37 | + if ut.isOlderVersion(product, version): |
| 38 | + logger.info("Skipping upgrade of {0}: {1} > {2}".format( |
| 39 | + product, ver_from, version)) |
| 40 | + return True |
| 41 | + |
| 42 | + logger.info("Upgrading {0}: {1} -> {2}".format(product, ver_from, version)) |
| 43 | + |
| 44 | + # -------- ADD YOUR STUFF BELOW -------- |
| 45 | + |
| 46 | + logger.info("{0} upgraded to version {1}".format(product, version)) |
| 47 | + return True |
0 commit comments