From 57e61666aa3208f083daaa4a80335ba9e71db71b Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 18 Jan 2023 00:48:35 +0100 Subject: [PATCH] Better validation error for validate version using new publisher --- openpype/plugins/publish/validate_version.py | 27 +++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/openpype/plugins/publish/validate_version.py b/openpype/plugins/publish/validate_version.py index b91633430f..9cda4dae90 100644 --- a/openpype/plugins/publish/validate_version.py +++ b/openpype/plugins/publish/validate_version.py @@ -1,4 +1,5 @@ import pyblish.api +from openpype.pipeline.publish import PublishValidationError class ValidateVersion(pyblish.api.InstancePlugin): @@ -20,11 +21,25 @@ class ValidateVersion(pyblish.api.InstancePlugin): version = instance.data.get("version") latest_version = instance.data.get("latestVersion") - if latest_version is not None: + if latest_version is not None and int(version) <= int(latest_version): + # TODO: Remove full non-html version upon drop of old publisher msg = ( - "Version `{0}` from instance `{1}` that you are trying to" - " publish, already exists in the database. Version in" - " database: `{2}`. Please version up your workfile to a higher" - " version number than: `{2}`." + "Version '{0}' from instance '{1}' that you are " + " trying to publish is lower or equal to an existing version " + " in the database. Version in database: '{2}'." + "Please version up your workfile to a higher version number " + "than: '{2}'." ).format(version, instance.data["name"], latest_version) - assert (int(version) > int(latest_version)), msg + + msg_html = ( + "Version {0} from instance {1} that you are " + " trying to publish is lower or equal to an existing version " + " in the database. Version in database: {2}.

" + "Please version up your workfile to a higher version number " + "than: {2}." + ).format(version, instance.data["name"], latest_version) + raise PublishValidationError( + title="Higher version of publish already exists", + message=msg, + description=msg_html + )