|
@ -4,7 +4,7 @@ |
|
|
"""Root factories for groups.""" |
|
|
"""Root factories for groups.""" |
|
|
|
|
|
|
|
|
from marshmallow.fields import String |
|
|
from marshmallow.fields import String |
|
|
from pyramid.httpexceptions import HTTPMovedPermanently |
|
|
|
|
|
|
|
|
from pyramid.httpexceptions import HTTPMovedPermanently, HTTPNotFound |
|
|
from pyramid.request import Request |
|
|
from pyramid.request import Request |
|
|
from sqlalchemy_utils import Ltree |
|
|
from sqlalchemy_utils import Ltree |
|
|
from webargs.pyramidparser import use_kwargs |
|
|
from webargs.pyramidparser import use_kwargs |
|
@ -44,4 +44,16 @@ def group_wiki_page_by_path(request: Request, wiki_page_path: str) -> GroupWikiP |
|
|
GroupWikiPage.group == group, GroupWikiPage.path == wiki_page_path |
|
|
GroupWikiPage.group == group, GroupWikiPage.path == wiki_page_path |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# try to return the page with the exact path, but catch if it doesn't exist |
|
|
|
|
|
try: |
|
|
|
|
|
return get_resource(request, query) |
|
|
|
|
|
except HTTPNotFound: |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
# if it didn't exist, try treating it as a folder and looking for an index page |
|
|
|
|
|
wiki_page_path += "/index" |
|
|
|
|
|
query = request.query(GroupWikiPage).filter( |
|
|
|
|
|
GroupWikiPage.group == group, GroupWikiPage.path == wiki_page_path |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
return get_resource(request, query) |
|
|
return get_resource(request, query) |