def test_get_default_workspace_menu_entry__ok__nominal_case(self):
        """
        Show only enabled app
        """
        app_config = Mock()
        app_config.APPS_COLORS = {}
        app_config.APPS_COLORS["primary"] = "#fff"
        thread = Application(
            label="Threads",
            slug="contents/thread",
            fa_icon="comments-o",
            is_active=True,
            config={},
            main_route="/ui/workspaces/{workspace_id}/contents?type=thread",
            app_config=app_config,
        )
        thread.add_content_type(
            slug="thread",
            label="Thread",
            creation_label="Start a topic",
            available_statuses=content_status_list.get_all(),
            file_extension=".thread.html",
        )

        markdownpluspage = Application(
            label="Markdown Plus Documents",
            # TODO - G.M - 24-05-2018 - Check label
            slug="contents/markdownpluspage",
            fa_icon="file-code-o",
            is_active=False,
            config={},
            main_route=
            "/ui/workspaces/{workspace_id}/contents?type=markdownpluspage",
            app_config=app_config,
        )
        markdownpluspage.add_content_type(
            slug="markdownpage",
            label="Rich Markdown File",
            creation_label="Create a Markdown document",
            available_statuses=content_status_list.get_all(),
        )
        app_api = ApplicationApi(app_list=[thread, markdownpluspage],
                                 show_all=False)
        workspace = Mock()
        workspace.workspace_id = 12
        workspace.agenda_enabled = True
        default_workspace_menu_entry = app_api.get_default_workspace_menu_entry(
            workspace=workspace)
        assert len(default_workspace_menu_entry) == 3
        assert default_workspace_menu_entry[
            0].label == dashboard_menu_entry.label
        assert default_workspace_menu_entry[
            1].label == all_content_menu_entry.label
        assert default_workspace_menu_entry[2].label == thread.label
Beispiel #2
0
 def load_content_types(self) -> None:
     content_type = TracimContentType(
         slug="folder",
         fa_icon=self.fa_icon,
         label="Folder",
         creation_label="Create a folder",
         available_statuses=content_status_list.get_all(),
         allow_sub_content=True,
         minimal_role_content_creation=WorkspaceRoles.CONTENT_MANAGER,
         app=self,
     )
     self.content_types.append(content_type)
Beispiel #3
0
 def load_content_types(self) -> None:
     content_type = TracimContentType(
         slug="file",
         fa_icon=self.fa_icon,
         label="File",
         creation_label="Upload files",
         available_statuses=content_status_list.get_all(),
         allow_sub_content=False,
         minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
         app=self,
     )
     self.content_types.append(content_type)
Beispiel #4
0
 def load_content_types(self) -> None:
     content_type = TracimContentType(
         slug="thread",
         fa_icon=self.fa_icon,
         label="Thread",
         creation_label="Start a topic",
         available_statuses=content_status_list.get_all(),
         allow_sub_content=False,
         file_extension=".thread.html",
         minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
         app=self,
     )
     self.content_types.append(content_type)
Beispiel #5
0
 def load_content_types(self) -> None:
     content_type = TracimContentType(
         slug="html-document",
         fa_icon=self.fa_icon,
         label="Text Document",
         creation_label="Write a document",
         available_statuses=content_status_list.get_all(),
         slug_aliases=["page"],
         allow_sub_content=False,
         file_extension=".document.html",
         minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
         app=self,
     )
     self.content_types.append(content_type)
Beispiel #6
0
 def load_content_types(self) -> None:
     content_type = TracimContentType(
         slug=THREAD_TYPE,
         fa_icon=self.fa_icon,
         label="Thread",
         creation_label="Start a topic",
         available_statuses=content_status_list.get_all(),
         allow_sub_content=False,
         file_extension=".thread.html",
         minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
         app=self,
     )
     self.content_types.append(content_type)
     MentionBuilder.register_content_type_parser(THREAD_TYPE,
                                                 DescriptionMentionParser())
Beispiel #7
0
 def load_content_types(self) -> None:
     content_type = TracimContentType(
         slug=HTML_DOCUMENTS_TYPE,
         fa_icon=self.fa_icon,
         label="Note",
         creation_label="Write a note",
         available_statuses=content_status_list.get_all(),
         slug_aliases=["page"],
         allow_sub_content=False,
         file_extension=".document.html",
         minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
         app=self,
     )
     self.content_types.append(content_type)
     MentionBuilder.register_content_type_parser(HTML_DOCUMENTS_TYPE,
                                                 DescriptionMentionParser())
Beispiel #8
0
    def test_get_default_workspace_menu_entry__ok__folder_case(self):
        """
        main route for folder is empty, that why it should not be included
        in default_menu entry
        :return:
        """
        app_config = Mock()
        app_config.APPS_COLORS = {}
        app_config.APPS_COLORS["primary"] = "#fff"

        folder = DummyApp(label="Folder",
                          slug="contents/folder",
                          fa_icon="folder-o",
                          config={},
                          main_route="")
        content_type = TracimContentType(
            slug="folder",
            fa_icon=folder.fa_icon,
            label="Folder",
            creation_label="Create a folder",
            available_statuses=content_status_list.get_all(),
            allow_sub_content=True,
            minimal_role_content_creation=WorkspaceRoles.CONTENT_MANAGER,
            app=folder,
        )
        folder.content_types.append(content_type)
        folder.is_active = True
        app_api = ApplicationApi(app_list=[folder], show_inactive=False)
        workspace = Mock()
        workspace.workspace_id = 12
        workspace.agenda_enabled = True
        default_workspace_menu_entry = app_api.get_default_workspace_menu_entry(
            workspace=workspace, app_config=app_config)
        assert len(default_workspace_menu_entry) == 3
        assert default_workspace_menu_entry[
            0].label == dashboard_menu_entry.label
        assert default_workspace_menu_entry[
            1].label == activity_menu_entry.label
        assert default_workspace_menu_entry[
            2].label == all_content_menu_entry.label
Beispiel #9
0
    def _set_default_app(self, enabled_app_list: typing.List[str]) -> None:

        # init applications
        html_documents = Application(
            label="Text Documents",  # TODO - G.M - 24-05-2018 - Check label
            slug="contents/html-document",
            fa_icon="file-text-o",
            is_active=True,
            config={},
            main_route=
            "/ui/workspaces/{workspace_id}/contents?type=html-document",
            app_config=self,
        )
        html_documents.add_content_type(
            slug="html-document",
            label="Text Document",
            creation_label="Write a document",
            available_statuses=content_status_list.get_all(),
            slug_alias=["page"],
            file_extension=".document.html",
        )

        _file = Application(
            label="Files",
            slug="contents/file",
            fa_icon="paperclip",
            is_active=True,
            config={},
            main_route="/ui/workspaces/{workspace_id}/contents?type=file",
            app_config=self,
        )
        _file.add_content_type(
            slug="file",
            label="File",
            creation_label="Upload a file",
            available_statuses=content_status_list.get_all(),
        )

        thread = Application(
            label="Threads",
            slug="contents/thread",
            fa_icon="comments-o",
            is_active=True,
            config={},
            main_route="/ui/workspaces/{workspace_id}/contents?type=thread",
            app_config=self,
        )
        thread.add_content_type(
            slug="thread",
            label="Thread",
            creation_label="Start a topic",
            available_statuses=content_status_list.get_all(),
            file_extension=".thread.html",
        )

        folder = Application(
            label="Folder",
            slug="contents/folder",
            fa_icon="folder-o",
            is_active=True,
            config={},
            main_route="",
            app_config=self,
        )
        folder.add_content_type(
            slug="folder",
            label="Folder",
            creation_label="Create a folder",
            available_statuses=content_status_list.get_all(),
            allow_sub_content=True,
            minimal_role_content_creation=WorkspaceRoles.CONTENT_MANAGER,
        )

        markdownpluspage = Application(
            label="Markdown Plus Documents",
            # TODO - G.M - 24-05-2018 - Check label
            slug="contents/markdownpluspage",
            fa_icon="file-code-o",
            is_active=False,
            config={},
            main_route=
            "/ui/workspaces/{workspace_id}/contents?type=markdownpluspage",
            app_config=self,
        )
        markdownpluspage.add_content_type(
            slug="markdownpage",
            label="Rich Markdown File",
            creation_label="Create a Markdown document",
            available_statuses=content_status_list.get_all(),
        )

        agenda = Application(
            label="Agenda",
            slug="agenda",
            fa_icon="calendar",
            is_active=self.CALDAV__ENABLED,
            config={},
            main_route="/ui/workspaces/{workspace_id}/agenda",
            app_config=self,
        )

        # process activated app list
        available_apps = OrderedDict([
            (html_documents.slug, html_documents),
            (_file.slug, _file),
            (thread.slug, thread),
            (folder.slug, folder),
            (markdownpluspage.slug, markdownpluspage),
            (agenda.slug, agenda),
        ])
        # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
        # of tracim_backend, Be careful app_list is a global_var
        app_list.clear()
        for app_slug in enabled_app_list:
            if app_slug in available_apps.keys():
                app_list.append(available_apps[app_slug])
        # TODO - G.M - 2018-08-08 - We need to update validators each time
        # app_list is updated.
        update_validators()
Beispiel #10
0
    def test_get_default_workspace_menu_entry__ok__nominal_case(self):
        """
        Show only enabled app
        """
        app_config = Mock()
        app_config.APPS_COLORS = {}
        app_config.APPS_COLORS["primary"] = "#fff"

        thread = DummyApp(
            label="Threads",
            slug="contents/thread",
            fa_icon="comments-o",
            config={},
            main_route="",
        )
        content_type = TracimContentType(
            slug="thread",
            fa_icon=thread.fa_icon,
            label="Thread",
            creation_label="Start a topic",
            available_statuses=content_status_list.get_all(),
            slug_aliases=["page"],
            allow_sub_content=False,
            file_extension=".thread.html",
            minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
            app=thread,
        )
        thread.content_types.append(content_type)

        markdownpluspage = DummyApp(
            label="Markdown Plus Documents",
            # TODO - G.M - 24-05-2018 - Check label
            slug="contents/markdownpluspage",
            fa_icon="file-code-o",
            config={},
            main_route="",
        )
        content_type = TracimContentType(
            slug="markdownpage",
            fa_icon=thread.fa_icon,
            label="Rich Markdown File",
            creation_label="Create a Markdown document",
            available_statuses=content_status_list.get_all(),
            allow_sub_content=False,
            file_extension=".md",
            minimal_role_content_creation=WorkspaceRoles.CONTRIBUTOR,
            app=thread,
        )
        markdownpluspage.content_types.append(content_type)
        thread.is_active = True
        markdownpluspage.is_active = False
        app_api = ApplicationApi(app_list=[thread, markdownpluspage],
                                 show_inactive=False)
        workspace = Mock()
        workspace.workspace_id = 12
        workspace.agenda_enabled = True
        default_workspace_menu_entry = app_api.get_default_workspace_menu_entry(
            workspace=workspace, app_config=app_config)
        assert len(default_workspace_menu_entry) == 2
        assert default_workspace_menu_entry[
            0].label == dashboard_menu_entry.label
        assert default_workspace_menu_entry[
            1].label == all_content_menu_entry.label
Beispiel #11
0
    def _set_default_app(self, enabled_app_list: typing.List[str]):

        # init applications
        html_documents = Application(
            label='Text Documents',  # TODO - G.M - 24-05-2018 - Check label
            slug='contents/html-document',
            fa_icon='file-text-o',
            is_active=True,
            config={},
            main_route=
            '/ui/workspaces/{workspace_id}/contents?type=html-document',
            app_config=self)
        html_documents.add_content_type(
            slug='html-document',
            label='Text Document',
            creation_label='Write a document',
            available_statuses=content_status_list.get_all(),
            slug_alias=['page'],
            file_extension='.document.html',
        )

        _file = Application(
            label='Files',
            slug='contents/file',
            fa_icon='paperclip',
            is_active=True,
            config={},
            main_route='/ui/workspaces/{workspace_id}/contents?type=file',
            app_config=self,
        )
        _file.add_content_type(
            slug='file',
            label='File',
            creation_label='Upload a file',
            available_statuses=content_status_list.get_all(),
        )

        thread = Application(
            label='Threads',
            slug='contents/thread',
            fa_icon='comments-o',
            is_active=True,
            config={},
            main_route='/ui/workspaces/{workspace_id}/contents?type=thread',
            app_config=self)
        thread.add_content_type(
            slug='thread',
            label='Thread',
            creation_label='Start a topic',
            available_statuses=content_status_list.get_all(),
            file_extension='.thread.html')

        folder = Application(label='Folder',
                             slug='contents/folder',
                             fa_icon='folder-open-o',
                             is_active=True,
                             config={},
                             main_route='',
                             app_config=self)
        folder.add_content_type(
            slug='folder',
            label='Folder',
            creation_label='Create a folder',
            available_statuses=content_status_list.get_all(),
            allow_sub_content=True,
        )

        markdownpluspage = Application(
            label='Markdown Plus Documents',
            # TODO - G.M - 24-05-2018 - Check label
            slug='contents/markdownpluspage',
            fa_icon='file-code-o',
            is_active=False,
            config={},
            main_route=
            '/ui/workspaces/{workspace_id}/contents?type=markdownpluspage',
            # nopep8
            app_config=self,
        )
        markdownpluspage.add_content_type(
            slug='markdownpage',
            label='Rich Markdown File',
            creation_label='Create a Markdown document',
            available_statuses=content_status_list.get_all(),
        )

        calendar = Application(
            label='Calendar',
            slug='calendar',
            fa_icon='calendar',
            is_active=False,
            config={},
            main_route='/ui/workspaces/{workspace_id}/calendar',
            app_config=self)

        # process activated app list
        available_apps = OrderedDict([(html_documents.slug, html_documents),
                                      (_file.slug, _file),
                                      (thread.slug, thread),
                                      (folder.slug, folder),
                                      (markdownpluspage.slug,
                                       markdownpluspage),
                                      (calendar.slug, calendar)])
        # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
        # of tracim_backend, Be careful app_list is a global_var
        app_list.clear()
        for app_slug in enabled_app_list:
            if app_slug in available_apps.keys():
                app_list.append(available_apps[app_slug])
        # TODO - G.M - 2018-08-08 - We need to update validators each time
        # app_list is updated.
        update_validators()
Beispiel #12
0
    def _set_default_app(self, enabled_app_list: typing.List[str]):

        # init applications
        html_documents = Application(
            label='Text Documents',  # TODO - G.M - 24-05-2018 - Check label
            slug='contents/html-document',
            fa_icon='file-text-o',
            is_active=True,
            config={},
            main_route='/ui/workspaces/{workspace_id}/contents?type=html-document',
            app_config=self
        )
        html_documents.add_content_type(
            slug='html-document',
            label='Text Document',
            creation_label='Write a document',
            available_statuses=content_status_list.get_all(),
            slug_alias=['page'],
            file_extension='.document.html',
        )

        _file = Application(
            label='Files',
            slug='contents/file',
            fa_icon='paperclip',
            is_active=True,
            config={},
            main_route='/ui/workspaces/{workspace_id}/contents?type=file',
            app_config=self,
        )
        _file.add_content_type(
            slug='file',
            label='File',
            creation_label='Upload a file',
            available_statuses=content_status_list.get_all(),
        )

        thread = Application(
            label='Threads',
            slug='contents/thread',
            fa_icon='comments-o',
            is_active=True,
            config={},
            main_route='/ui/workspaces/{workspace_id}/contents?type=thread',
            app_config=self
        )
        thread.add_content_type(
            slug='thread',
            label='Thread',
            creation_label='Start a topic',
            available_statuses=content_status_list.get_all(),
            file_extension='.thread.html'
        )

        folder = Application(
            label='Folder',
            slug='contents/folder',
            fa_icon='folder-o',
            is_active=True,
            config={},
            main_route='',
            app_config=self
        )
        folder.add_content_type(
            slug='folder',
            label='Folder',
            creation_label='Create a folder',
            available_statuses=content_status_list.get_all(),
            allow_sub_content=True,
            minimal_role_content_creation=WorkspaceRoles.CONTENT_MANAGER
        )

        markdownpluspage = Application(
            label='Markdown Plus Documents',
            # TODO - G.M - 24-05-2018 - Check label
            slug='contents/markdownpluspage',
            fa_icon='file-code-o',
            is_active=False,
            config={},
            main_route='/ui/workspaces/{workspace_id}/contents?type=markdownpluspage',
            # nopep8
            app_config=self,
        )
        markdownpluspage.add_content_type(
            slug='markdownpage',
            label='Rich Markdown File',
            creation_label='Create a Markdown document',
            available_statuses=content_status_list.get_all(),
        )

        calendar = Application(
            label='Calendar',
            slug='calendar',
            fa_icon='calendar',
            is_active=False,
            config={},
            main_route='/ui/workspaces/{workspace_id}/calendar',
            app_config=self
        )

        # process activated app list
        available_apps = OrderedDict([
            (html_documents.slug, html_documents),
            (_file.slug, _file),
            (thread.slug, thread),
            (folder.slug, folder),
            (markdownpluspage.slug, markdownpluspage),
            (calendar.slug, calendar)
        ])
        # TODO - G.M - 2018-08-08 - [GlobalVar] Refactor Global var
        # of tracim_backend, Be careful app_list is a global_var
        app_list.clear()
        for app_slug in enabled_app_list:
            if app_slug in available_apps.keys():
                app_list.append(available_apps[app_slug])
        # TODO - G.M - 2018-08-08 - We need to update validators each time
        # app_list is updated.
        update_validators()