From 5eba6d11c52d4bd265c463b1878a9bbc4c62c4c7 Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 16 Oct 2023 13:36:03 +0100 Subject: [PATCH 1/2] make sure ArticleNotAcceptable exception is caught correctly and message is displayed as an error --- portality/bll/services/article.py | 2 ++ portality/view/publisher.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/portality/bll/services/article.py b/portality/bll/services/article.py index b5e829cd24..52ce61fb20 100644 --- a/portality/bll/services/article.py +++ b/portality/bll/services/article.py @@ -219,6 +219,8 @@ def create_article(self, article, account, duplicate_check=True, merge_duplicate # We do this after the permissions check because that gives a detailed result whereas this throws an exception try: self.is_acceptable(article) + except exceptions.ArticleNotAcceptable as e: + raise exceptions.ArticleNotAcceptable(message=e.message) except Exception as e: raise e diff --git a/portality/view/publisher.py b/portality/view/publisher.py index 2410a8323a..c525ce176c 100644 --- a/portality/view/publisher.py +++ b/portality/view/publisher.py @@ -4,7 +4,7 @@ from portality.app_email import EmailException from portality import models -from portality.bll.exceptions import AuthoriseException, ArticleMergeConflict, DuplicateArticleException +from portality.bll.exceptions import AuthoriseException, ArticleMergeConflict, DuplicateArticleException, ArticleNotAcceptable from portality.decorators import ssl_required, restrict_to_role, write_required from portality.dao import ESMappingMissingError from portality.forms.application_forms import ApplicationFormFactory @@ -362,7 +362,8 @@ def metadata(): Messages.flash(Messages.ARTICLE_METADATA_MERGE_CONFLICT) except DuplicateArticleException: Messages.flash(Messages.ARTICLE_METADATA_UPDATE_CONFLICT) - + except ArticleNotAcceptable as e: + Messages.flash_with_param(e.message, "error") return fc.render_template(validated=validated) From 43b8c9edc1bbaea3f8e6bc090214621edc1840aa Mon Sep 17 00:00:00 2001 From: Aga Date: Wed, 18 Oct 2023 09:57:35 +0100 Subject: [PATCH 2/2] remove unnecessary code --- portality/bll/services/article.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/portality/bll/services/article.py b/portality/bll/services/article.py index 52ce61fb20..b5e829cd24 100644 --- a/portality/bll/services/article.py +++ b/portality/bll/services/article.py @@ -219,8 +219,6 @@ def create_article(self, article, account, duplicate_check=True, merge_duplicate # We do this after the permissions check because that gives a detailed result whereas this throws an exception try: self.is_acceptable(article) - except exceptions.ArticleNotAcceptable as e: - raise exceptions.ArticleNotAcceptable(message=e.message) except Exception as e: raise e