コード例 #1
0
ファイル: content.py プロジェクト: qyqx/tracim
    def create(self,
               content_type: str,
               workspace: Workspace,
               parent: Content = None,
               label: str = '',
               do_save=False,
               is_temporary: bool = False) -> Content:
        assert content_type in ContentType.allowed_types()

        if content_type == ContentType.Folder and not label:
            label = self.generate_folder_label(workspace, parent)

        content = Content()
        content.owner = self._user
        content.parent = parent
        content.workspace = workspace
        content.type = content_type
        content.label = label
        content.is_temporary = is_temporary
        content.revision_type = ActionDescription.CREATION

        if content.type in (
                ContentType.Page,
                ContentType.Thread,
        ):
            content.file_extension = '.html'

        if do_save:
            DBSession.add(content)
            self.save(content, ActionDescription.CREATION)
        return content
コード例 #2
0
ファイル: content.py プロジェクト: lebouquetin/tracim
    def create(self, content_type: str, workspace: Workspace, parent: Content=None, label:str ='', do_save=False, is_temporary: bool=False) -> Content:
        assert content_type in ContentType.allowed_types()

        if content_type == ContentType.Folder and not label:
            label = self.generate_folder_label(workspace, parent)

        content = Content()
        content.owner = self._user
        content.parent = parent
        content.workspace = workspace
        content.type = content_type
        content.label = label
        content.is_temporary = is_temporary
        content.revision_type = ActionDescription.CREATION

        if content.type in (
                ContentType.Page,
                ContentType.Thread,
        ):
            content.file_extension = '.html'

        if do_save:
            DBSession.add(content)
            self.save(content, ActionDescription.CREATION)
        return content
コード例 #3
0
ファイル: content.py プロジェクト: buxx/tracim
 def update_file_data(self, item: Content, new_filename: str, new_mimetype: str, new_file_content) -> Content:
     item.owner = self._user
     item.file_name = new_filename
     item.file_mimetype = new_mimetype
     item.file_content = new_file_content
     item.revision_type = ActionDescription.REVISION
     return item
コード例 #4
0
 def update_file_data(self, item: Content, new_filename: str,
                      new_mimetype: str, new_file_content) -> Content:
     item.owner = self._user
     item.file_name = new_filename
     item.file_mimetype = new_mimetype
     item.file_content = new_file_content
     item.revision_type = ActionDescription.REVISION
     return item
コード例 #5
0
ファイル: content.py プロジェクト: buxx/tracim
 def update_content(self, item: Content, new_label: str, new_content: str=None) -> Content:
     if item.label==new_label and item.description==new_content:
         raise SameValueError(_('The content did not changed'))
     item.owner = self._user
     item.label = new_label
     item.description = new_content if new_content else item.description # TODO: convert urls into links
     item.revision_type = ActionDescription.EDITION
     return item
コード例 #6
0
 def update_content(self, item: Content, new_label: str, new_content: str=None) -> Content:
     if item.label==new_label and item.description==new_content:
         raise SameValueError(_('The content did not changed'))
     item.owner = self._user
     item.label = new_label
     item.description = new_content if new_content else item.description # TODO: convert urls into links
     item.revision_type = ActionDescription.EDITION
     return item
コード例 #7
0
ファイル: content.py プロジェクト: lebouquetin/tracim
 def update_file_data(self, item: Content, new_filename: str, new_mimetype: str, new_content: bytes) -> Content:
     item.owner = self._user
     item.file_name = new_filename
     item.file_mimetype = new_mimetype
     item.depot_file = FileIntent(
         new_content,
         new_filename,
         new_mimetype,
     )
     item.revision_type = ActionDescription.REVISION
     return item
コード例 #8
0
 def update_file_data(self, item: Content, new_filename: str, new_mimetype: str, new_content: bytes) -> Content:
     item.owner = self._user
     item.file_name = new_filename
     item.file_mimetype = new_mimetype
     item.depot_file = FileIntent(
         new_content,
         new_filename,
         new_mimetype,
     )
     item.revision_type = ActionDescription.REVISION
     return item
コード例 #9
0
ファイル: content.py プロジェクト: buxx/tracim
    def create_comment(self, workspace: Workspace=None, parent: Content=None, content:str ='', do_save=False) -> Content:
        assert parent  and parent.type!=ContentType.Folder
        item = Content()
        item.owner = self._user
        item.parent = parent
        item.workspace = workspace
        item.type = ContentType.Comment
        item.description = content
        item.label = ''
        item.revision_type = ActionDescription.COMMENT

        if do_save:
            self.save(item, ActionDescription.COMMENT)
        return item
コード例 #10
0
    def create_comment(self, workspace: Workspace=None, parent: Content=None, content:str ='', do_save=False) -> Content:
        assert parent  and parent.type!=ContentType.Folder
        item = Content()
        item.owner = self._user
        item.parent = parent
        item.workspace = workspace
        item.type = ContentType.Comment
        item.description = content
        item.label = ''
        item.revision_type = ActionDescription.COMMENT

        if do_save:
            self.save(item, ActionDescription.COMMENT)
        return item
コード例 #11
0
ファイル: content.py プロジェクト: DarkDare/tracim
    def create(self, content_type: str, workspace: Workspace, parent: Content=None, label:str ='', do_save=False) -> Content:
        assert content_type in ContentType.allowed_types()
        content = Content()
        content.owner = self._user
        content.parent = parent
        content.workspace = workspace
        content.type = content_type
        content.label = label
        content.revision_type = ActionDescription.CREATION

        if do_save:
            DBSession.add(content)
            self.save(content, ActionDescription.CREATION)
        return content
コード例 #12
0
    def create(self,
               content_type: str,
               workspace: Workspace,
               parent: Content = None,
               label: str = '',
               is_temporary: bool = False,
               do_save=False) -> Content:
        assert content_type in ContentType.allowed_types()
        content = Content()
        content.owner = self._user
        content.parent = parent
        content.workspace = workspace
        content.type = content_type
        content.label = label
        content.is_temporary = is_temporary
        content.revision_type = ActionDescription.CREATION

        if do_save:
            DBSession.add(content)
            self.save(content, ActionDescription.CREATION)
        return content
コード例 #13
0
ファイル: content.py プロジェクト: buxx/tracim
 def undelete(self, content: Content):
     content.owner = self._user
     content.is_deleted = False
     content.revision_type = ActionDescription.UNDELETION
コード例 #14
0
ファイル: content.py プロジェクト: buxx/tracim
 def delete(self, content: Content):
     content.owner = self._user
     content.is_deleted = True
     content.revision_type = ActionDescription.DELETION
コード例 #15
0
ファイル: content.py プロジェクト: qyqx/tracim
 def delete(self, content: Content):
     content.owner = self._user
     content.is_deleted = True
     content.revision_type = ActionDescription.DELETION
コード例 #16
0
ファイル: content.py プロジェクト: qyqx/tracim
 def archive(self, content: Content):
     content.owner = self._user
     content.is_archived = True
     content.revision_type = ActionDescription.ARCHIVING
コード例 #17
0
ファイル: content.py プロジェクト: qyqx/tracim
 def unarchive(self, content: Content):
     content.owner = self._user
     content.is_archived = False
     content.revision_type = ActionDescription.UNARCHIVING
コード例 #18
0
ファイル: content.py プロジェクト: buxx/tracim
 def archive(self, content: Content):
     content.owner = self._user
     content.is_archived = True
     content.revision_type = ActionDescription.ARCHIVING
コード例 #19
0
ファイル: content.py プロジェクト: qyqx/tracim
 def undelete(self, content: Content):
     content.owner = self._user
     content.is_deleted = False
     content.revision_type = ActionDescription.UNDELETION
コード例 #20
0
ファイル: content.py プロジェクト: buxx/tracim
 def unarchive(self, content: Content):
     content.owner = self._user
     content.is_archived = False
     content.revision_type = ActionDescription.UNARCHIVING