当前位置: 首页>>代码示例>>Python>>正文


Python ContentApi.find_one_by_unique_property方法代码示例

本文整理汇总了Python中tracim.lib.content.ContentApi.find_one_by_unique_property方法的典型用法代码示例。如果您正苦于以下问题:Python ContentApi.find_one_by_unique_property方法的具体用法?Python ContentApi.find_one_by_unique_property怎么用?Python ContentApi.find_one_by_unique_property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tracim.lib.content.ContentApi的用法示例。


在下文中一共展示了ContentApi.find_one_by_unique_property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_event

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import find_one_by_unique_property [as 别名]
    def update_event(
            self,
            calendar: Calendar,
            event: iCalendarEvent,
            event_name: str,
            current_user: User,
    ) -> Content:
        """
        Update Content Event
        :param calendar: Event calendar owner
        :param event: ICS event
        :param event_name: Event name (ID) like
        20160602T083511Z-18100-1001-1-71_Bastien-20160602T083516Z.ics
        :param current_user: Current modification asking user
        :return: Updated Content
        """
        workspace = None
        if isinstance(calendar, WorkspaceCalendar):
            workspace = calendar.related_object
        elif isinstance(calendar, UserCalendar):
            pass
        else:
            raise UnknownCalendarType('Type "{0}" is not implemented'
                                      .format(type(calendar)))

        content_api = ContentApi(
            current_user,
            force_show_all_types=True,
            disable_user_workspaces_filter=True
        )
        content = content_api.find_one_by_unique_property(
            property_name='name',
            property_value=event_name,
            workspace=workspace
        )

        with new_revision(content):
            self.populate_content_with_event(
                content,
                event,
                event_name
            )
            content.revision_type = ActionDescription.EDITION

        DBSession.flush()
        transaction.commit()

        return content
开发者ID:buxx,项目名称:tracim,代码行数:50,代码来源:calendar.py

示例2: delete_event_with_name

# 需要导入模块: from tracim.lib.content import ContentApi [as 别名]
# 或者: from tracim.lib.content.ContentApi import find_one_by_unique_property [as 别名]
    def delete_event_with_name(self, event_name: str, current_user: User)\
            -> Content:
        """
        Delete Content Event
        :param event_name: Event name (ID) like
        20160602T083511Z-18100-1001-1-71_Bastien-20160602T083516Z.ics
        :param current_user: Current deletion asking user
        :return: Deleted Content
        """
        content_api = ContentApi(current_user, force_show_all_types=True)
        content = content_api.find_one_by_unique_property(
            property_name='name',
            property_value=event_name,
            workspace=None
        )

        with new_revision(content):
            content_api.delete(content)

        DBSession.flush()
        transaction.commit()

        return content
开发者ID:buxx,项目名称:tracim,代码行数:25,代码来源:calendar.py


注:本文中的tracim.lib.content.ContentApi.find_one_by_unique_property方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。