From fdf3b440e103c59e383f1ea58e2d6882e8251dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominic=20K=C3=B6nig?= Date: Wed, 16 Feb 2022 20:30:28 +0100 Subject: [PATCH] Release RLPPTM-1.17.1 --- VERSION | 2 +- .../templates/RLPPTM/upgrade/1.17.0-1.17.1.py | 78 +++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 modules/templates/RLPPTM/upgrade/1.17.0-1.17.1.py diff --git a/VERSION b/VERSION index 763b9370e..9b5fa8f15 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -RLPPTM-1.17.0 (2022-02-11 14:02:24) +RLPPTM-1.17.1 (2022-02-16 20:02:28) diff --git a/modules/templates/RLPPTM/upgrade/1.17.0-1.17.1.py b/modules/templates/RLPPTM/upgrade/1.17.0-1.17.1.py new file mode 100644 index 000000000..ef9a2433c --- /dev/null +++ b/modules/templates/RLPPTM/upgrade/1.17.0-1.17.1.py @@ -0,0 +1,78 @@ +# Database upgrade script +# +# RLPPTM Template Version 1.17.0 => 1.17.1 +# +# Execute in web2py folder after code upgrade like: +# python web2py.py -S eden -M -R applications/eden/modules/templates/RLPPTM/upgrade/1.17.0-1.17.1.py +# +import sys + +from core import S3Duplicate + +# Override auth (disables all permission checks) +auth.override = True + +# Failed-flag +failed = False + +# Info +def info(msg): + sys.stderr.write("%s" % msg) +def infoln(msg): + sys.stderr.write("%s\n" % msg) + +# Load models for tables +otable = s3db.org_organisation + +IMPORT_XSLT_FOLDER = os.path.join(request.folder, "static", "formats", "s3csv") +TEMPLATE_FOLDER = os.path.join(request.folder, "modules", "templates", "RLPPTM") + +# ----------------------------------------------------------------------------- +# Deploy new CMS items +# +if not failed: + info("Deploy new CMS items") + + # File and Stylesheet Paths + stylesheet = os.path.join(IMPORT_XSLT_FOLDER, "cms", "post.xsl") + filename = os.path.join(TEMPLATE_FOLDER, "cms_post.csv") + + # Only import relevant CMS posts, do not update any existing ones + def cms_post_duplicate(item): + name = item.data.get("name") + if name in ("TestStationManagerRequirements", + ): + S3Duplicate(noupdate=True)(item) + else: + item.skip = True + + # Import, fail on any errors + try: + with open(filename, "r") as File: + resource = s3db.resource("cms_post") + resource.configure(deduplicate = cms_post_duplicate) + resource.import_xml(File, + source_type = "csv", + stylesheet = stylesheet, + ) + except: + infoln("...failed") + infoln(sys.exc_info()[1]) + failed = True + else: + if resource.error: + infoln("...failed") + infoln(resource.error) + failed = True + else: + infoln("...done") + +# ----------------------------------------------------------------------------- +# Finishing up +# +if failed: + db.rollback() + infoln("UPGRADE FAILED - Action rolled back.") +else: + db.commit() + infoln("UPGRADE SUCCESSFUL.")