diff --git a/VERSION b/VERSION index 54aa56fad..4196dbdd9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -GIMS-1.0.2 (2022-03-29 11:03:16) +GIMS-1.0.3 (2022-04-05 14:04:21) diff --git a/modules/templates/GIMS/upgrade/1.0.2-1.0.3.py b/modules/templates/GIMS/upgrade/1.0.2-1.0.3.py new file mode 100644 index 000000000..b643c6b33 --- /dev/null +++ b/modules/templates/GIMS/upgrade/1.0.2-1.0.3.py @@ -0,0 +1,57 @@ +# Database upgrade script +# +# GIMS Template Version 1.0.2 => 1.0.3 +# +# Execute in web2py folder after code upgrade like: +# python web2py.py -S eden -M -R applications/eden/modules/templates/GIMS/upgrade/1.0.2-1.0.3.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", "GIMS") + +# ----------------------------------------------------------------------------- +# Upgrade user roles +# +if not failed: + info("Upgrade user roles") + + bi = s3base.BulkImporter() + filename = os.path.join(TEMPLATE_FOLDER, "auth_roles.csv") + + with open(filename, "r") as File: + try: + bi.import_roles(filename) + except Exception as e: + infoln("...failed") + infoln(sys.exc_info()[1]) + failed = True + else: + infoln("...done") + +# ----------------------------------------------------------------------------- +# Finishing up +# +if failed: + db.rollback() + infoln("UPGRADE FAILED - Action rolled back.") +else: + db.commit() + infoln("UPGRADE SUCCESSFUL.")