Browse Source

GroupWikiPage: add slug property

Not needed for much yet, but should be used here anyway to prevent
"new_page" pages from being created inside folders (which isn't possible
yet anyway).
merge-requests/76/merge
Deimos 5 years ago
parent
commit
a64a4ca58c
  1. 7
      tildes/tildes/models/group/group_wiki_page.py

7
tildes/tildes/models/group/group_wiki_page.py

@ -61,7 +61,7 @@ class GroupWikiPage(DatabaseModel):
self.path = convert_to_url_slug(page_name)
# prevent possible conflict with url for creating a new page
if self.path == "new_page":
if self.slug == "new_page":
raise ValueError("Invalid page name")
if self.file_path.exists():
@ -99,6 +99,11 @@ class GroupWikiPage(DatabaseModel):
"""Return a relative path to the page's file."""
return Path(str(self.group.path), f"{self.path}.md")
@property
def slug(self) -> str:
"""Return the page's slug, which is also its filename with no extension."""
return self.file_path.stem
@property
def history_url(self) -> str:
"""Return a url to the page's edit history."""

Loading…
Cancel
Save