Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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())
Esempio n. 6
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())
Esempio n. 7
0
    def test__unit__ContentTypeCreationChecker__err__implicit_insufficent_role_in_workspace(
            self, session):

        current_user = User(user_id=2, email="*****@*****.**")
        current_user.profile = Profile.TRUSTED_USER
        current_workspace = Workspace(workspace_id=3, owner=current_user)
        candidate_content_type = TracimContentType(
            slug="test",
            fa_icon="",
            label="Test",
            creation_label="Test",
            available_statuses=[],
            minimal_role_content_creation=WorkspaceRoles.CONTENT_MANAGER,
        )
        role = UserRoleInWorkspace(user_id=2,
                                   workspace_id=3,
                                   role=WorkspaceRoles.CONTRIBUTOR.level)
        session.add(current_user)
        session.add(current_workspace)
        session.add(role)
        session.flush()
        transaction.commit()

        class FakeContentTypeList(object):
            def get_one_by_slug(self, slug=str) -> TracimContentType:
                return candidate_content_type

        class FakeBaseFakeTracimContext(BaseFakeTracimContext):
            @property
            def current_user(self):
                return current_user

            @property
            def current_workspace(self):
                return current_workspace

            @property
            def candidate_content_type(self):
                return candidate_content_type

        with pytest.raises(InsufficientUserRoleInWorkspace):
            assert ContentTypeCreationChecker(FakeContentTypeList()).check(
                FakeBaseFakeTracimContext())
Esempio n. 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
Esempio n. 9
0
    def file_extension(self) -> str:
        return self.content_type.file_extension


THREAD_TYPE = "thread"
FILE_TYPE = "file"
MARKDOWNPLUSPAGE_TYPE = "markdownpage"
HTML_DOCUMENTS_TYPE = "html-document"
FOLDER_TYPE = "folder"
COMMENT_TYPE = "comment"

# TODO - G.M - 31-05-2018 - Set Better Event params
event_type = TracimContentType(
    slug="event",
    fa_icon="",
    label="Event",
    creation_label="Event",
    available_statuses=content_status_list.get_all(),
    app=None,
)

# TODO - G.M - 31-05-2018 - Set Better Event params
comment_type = TracimContentType(
    slug=COMMENT_TYPE,
    fa_icon="",
    label="Comment",
    creation_label="Comment",
    available_statuses=content_status_list.get_all(),
)


class ContentTypeList(object):
Esempio n. 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