diff --git a/VERSION b/VERSION index 7a1b208f2..3f40d3a3f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -RLPPTM-1.21.1 (2023-07-03 22:07:22) +RLPPTM-1.21.2 (2023-08-10 22:08:48) diff --git a/modules/templates/RLPPTM/upgrade/1.21.1-1.21.2.py b/modules/templates/RLPPTM/upgrade/1.21.1-1.21.2.py new file mode 100644 index 000000000..ab5def044 --- /dev/null +++ b/modules/templates/RLPPTM/upgrade/1.21.1-1.21.2.py @@ -0,0 +1,64 @@ +# Database upgrade script +# +# RLPPTM Template Version 1.21.1 => 1.21.2 +# +# Execute in web2py folder after code upgrade like: +# python web2py.py -S eden -M -R applications/eden/modules/templates/RLPPTM/upgrade/1.21.1-1.21.2.py +# +import sys + +#from core import S3Duplicate +#from templates.RLPPTM.models.org import TestProvider + +# Override auth (disables all permission checks) +auth.override = True + +# Initialize failed-flag +failed = False + +# Info +def info(msg): + sys.stderr.write("%s" % msg) + sys.stderr.flush() +def infoln(msg): + sys.stderr.write("%s\n" % msg) + sys.stderr.flush() + +# Load models for tables +#rtable = s3db.org_representative + +# Paths +IMPORT_XSLT_FOLDER = os.path.join(request.folder, "static", "formats", "s3csv") +TEMPLATE_FOLDER = os.path.join(request.folder, "modules", "templates", "RLPPTM") + +# ----------------------------------------------------------------------------- +# Upgrade user roles +# +if not failed: + info("Upgrade user roles") + + bi = s3base.BulkImporter() + filename = os.path.join(TEMPLATE_FOLDER, "auth_roles.csv") + + try: + error = bi.import_roles(filename) + except Exception as e: + error = sys.exc_info()[1] or "unknown error" + if error: + infoln("...failed") + infoln(error) + failed = True + else: + infoln("...done") + +# ----------------------------------------------------------------------------- +# Finishing up +# +if failed: + db.rollback() + infoln("UPGRADE FAILED - Action rolled back.") +else: + db.commit() + infoln("UPGRADE SUCCESSFUL.") + +# END =========================================================================