Skip to content

Commit

Permalink
make sure ArticleNotAcceptable exception is caught correctly and mess…
Browse files Browse the repository at this point in the history
…age is displayed as an error
  • Loading branch information
amdomanska committed Oct 16, 2023
1 parent 0f27c23 commit 5eba6d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions portality/bll/services/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions portality/view/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 5eba6d1

Please sign in to comment.