Skip to content

Commit

Permalink
refactor: updated comment and code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatimah committed Feb 19, 2024
1 parent eafca00 commit 3dc8d80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 1 addition & 5 deletions invenio_pages/records/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ def __repr__(self):
Used on Page admin view in inline model.
:returns: unambiguous page representation.
"""
return "URL: %s, title: %s, has_custom_view: %s" % (
self.url,
self.title,
self.has_custom_view,
)
return f"URL: {self.url}, title: {self.title}, has_custom_view: {self.has_custom_view}"


class PageList(db.Model):
Expand Down
6 changes: 4 additions & 2 deletions invenio_pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

@blueprint.before_app_first_request
def register_pages():
"""Register URL rule of all static pages to the application."""
"""Register URL rule of all static pages to the application skipping those with custom views,
to add URL rules for each to the application. This allows default handling for pages without
customizations."""
# We need to set the function view, to be able to directly register the urls in the Flask.url_map
current_app.view_functions["invenio_pages.view"] = view

for page in Page.query.all():
if not page.has_custom_view: # Check if page does not have a custom view
if not page.has_custom_view: # Skip registration of pages with custom view
_add_url_rule(page.url)


Expand Down

0 comments on commit 3dc8d80

Please sign in to comment.