def initialize_wiki(): try: root = URLPath.root() except NoRootURL: print("Root URL not found, creating...") root = URLPath.create_root(title="QUOREM Wiki", content=get_content_from_file( "quorem/static/markdown/docs/root.md")) article_revision = ArticleRevision( title=root.article.current_revision.title, content=get_content_from_file("quorem/static/markdown/docs/root.md")) root.article.add_revision(article_revision) try: investigation = URLPath.get_by_path("investigation") except URLPath.DoesNotExist: print("Investigation page not found, creating...") URLPath.create_urlpath(root, slug="investigation", title="List of Investigations", content="""This page lists the investigations that are present in your QUOREM database. You may edit anything on this page, except the Automated Report section.\r\n\r\n""") try: protocol = URLPath.get_by_path("protocol") except URLPath.DoesNotExist: print("Protocol page not found, creating...") URLPath.create_urlpath(root, slug="protocol", title="List of Protocols", content="""This page lists the protocols that are present in your QUOREM database. You may edit anything on this page, except the Automated Report section.\r\n\r\n""") try: pipeline = URLPath.get_by_path("pipeline") except URLPath.DoesNotExist: print("Pipeline page not found, creating...") URLPath.create_urlpath(root, slug="pipeline", title="List of Pipelines", content="""This page lists the pipelines that are present in your QUOREM database. You may edit anything on this page, except the Automated Report section.\r\n\r\n""") try: sample = URLPath.get_by_path("sample") except URLPath.DoesNotExist: print("Sample page not found, creating...") URLPath.create_urlpath( root, slug="sample", title="List of Samples", content= "This page lists the samples that are present in your QUOREM database. You may edit anything on this page, except the Automated Report section.\r\n\r\n" ) initialize_documentation(root)
def get_root(self): try: base_root = URLPath.get_by_path(path="") except NoRootURL: if (self.slug == "root") and (self.prefix == "/"): root = URLPath.create_root(title="QUOREM Wiki", content=self.content) return root else: raise ValueError( "No root created for prefix '%s'. Make sure root.md is processed first" % (self.prefix, )) try: root = URLPath.get_by_path(self.prefix) except URLPath.DoesNotExist: if (self.slug == "root") and (self.prefix != "/"): root = URLPath.create_urlpath(base_root, slug=self.prefix, title=self.title, content=self.content) else: raise ValueError("No root created for prefix '%s'." % (self.prefix, )) return root
def _create_root(self): root = URLPath.create_root(title="QUOR'em Wiki", content=self.content) return root