def test_get_default_workspace_menu_entry__ok__agenda_disabled_workspace_case(
            self):
        app_config = Mock()
        app_config.APPS_COLORS = {}
        app_config.APPS_COLORS["primary"] = "#fff"

        agenda = Application(
            label="Agenda",
            slug="agenda",
            fa_icon="calendar",
            is_active=True,
            config={},
            main_route="/ui/workspaces/{workspace_id}/agenda",
            app_config=app_config,
        )
        app_api = ApplicationApi(app_list=[agenda], show_all=False)
        workspace = Mock()
        workspace.workspace_id = 12
        workspace.agenda_enabled = False
        default_workspace_menu_entry = app_api.get_default_workspace_menu_entry(
            workspace=workspace)
        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
    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
    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 = Application(
            label="Folder",
            slug="contents/folder",
            fa_icon="folder-o",
            is_active=True,
            config={},
            main_route="",
            app_config=app_config,
        )
        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,
        )
        app_api = ApplicationApi(app_list=[folder], 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) == 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 #4
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 #5
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 #6
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()