Skip to content

Commit

Permalink
pages: do not create a static page if it already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
anikachurilova authored and ntarocco committed Dec 13, 2024
1 parent 8130283 commit ecbbc0f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions invenio_app_rdm/fixtures/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from invenio_access.permissions import system_identity
from invenio_db import db
from invenio_pages.proxies import current_pages_service
from invenio_pages.records.errors import PageNotFoundError
from invenio_rdm_records.fixtures.fixture import FixtureMixin


Expand Down Expand Up @@ -45,11 +46,15 @@ def page_data(self, page):

def create(self, entry):
"""Load a single page."""
data = {
"url": entry.pop("url"),
"title": entry.get("title"),
"content": self.page_data(entry.get("template")),
"description": entry.get("description"),
"template_name": current_app.config["PAGES_DEFAULT_TEMPLATE"],
}
current_pages_service.create(system_identity, data)
url = entry["url"]
try:
current_pages_service.read_by_url(system_identity, url)
except PageNotFoundError:
data = {
"url": url,
"title": entry.get("title", ""),
"content": self.page_data(entry["template"]),
"description": entry.get("description", ""),
"template_name": current_app.config["PAGES_DEFAULT_TEMPLATE"],
}
current_pages_service.create(system_identity, data)

0 comments on commit ecbbc0f

Please sign in to comment.