• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python services.make_key_from_model_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中taiga.projects.history.services.make_key_from_model_object函数的典型用法代码示例。如果您正苦于以下问题:Python make_key_from_model_object函数的具体用法?Python make_key_from_model_object怎么用?Python make_key_from_model_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: data_wiki

def data_wiki(data):
    m = type("Models", (object,), {})
    m.public_wiki = f.WikiPageFactory(project=data.public_project, slug=4)
    m.public_history_entry = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.public_project,
        comment="testing public",
        key=make_key_from_model_object(m.public_wiki),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )

    m.private_wiki1 = f.WikiPageFactory(project=data.private_project1, slug=8)
    m.private_history_entry1 = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.private_project1,
        comment="testing 1",
        key=make_key_from_model_object(m.private_wiki1),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )
    m.private_wiki2 = f.WikiPageFactory(project=data.private_project2, slug=12)
    m.private_history_entry2 = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.private_project2,
        comment="testing 2",
        key=make_key_from_model_object(m.private_wiki2),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )
    return m
开发者ID:Cyrilplus,项目名称:taiga-back,代码行数:31,代码来源:test_history_resources.py


示例2: data_issue

def data_issue(data):
    m = type("Models", (object,), {})
    m.public_issue = f.IssueFactory(project=data.public_project, ref=3)
    m.public_history_entry = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.public_project,
        comment="testing public",
        key=make_key_from_model_object(m.public_issue),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )

    m.private_issue1 = f.IssueFactory(project=data.private_project1, ref=7)
    m.private_history_entry1 = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.private_project1,
        comment="testing 1",
        key=make_key_from_model_object(m.private_issue1),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )
    m.private_issue2 = f.IssueFactory(project=data.private_project2, ref=11)
    m.private_history_entry2 = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.private_project2,
        comment="testing 2",
        key=make_key_from_model_object(m.private_issue2),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )
    return m
开发者ID:Cyrilplus,项目名称:taiga-back,代码行数:31,代码来源:test_history_resources.py


示例3: data_task

def data_task(data):
    m = type("Models", (object,), {})
    m.public_task = f.TaskFactory(project=data.public_project, ref=2)
    m.public_history_entry = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.public_project,
        comment="testing public",
        key=make_key_from_model_object(m.public_task),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )

    m.private_task1 = f.TaskFactory(project=data.private_project1, ref=6)
    m.private_history_entry1 = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.private_project1,
        comment="testing 1",
        key=make_key_from_model_object(m.private_task1),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )
    m.private_task2 = f.TaskFactory(project=data.private_project2, ref=10)
    m.private_history_entry2 = f.HistoryEntryFactory.create(
        type=HistoryType.change,
        project=data.private_project2,
        comment="testing 2",
        key=make_key_from_model_object(m.private_task2),
        diff={},
        user={"pk": data.project_member_with_perms.pk},
    )
    return m
开发者ID:Cyrilplus,项目名称:taiga-back,代码行数:31,代码来源:test_history_resources.py


示例4: send_notifications

def send_notifications(obj, *, history):
    if history.is_hidden:
        return None

    key = make_key_from_model_object(obj)
    owner = User.objects.get(pk=history.user["pk"])
    notification, created = (HistoryChangeNotification.objects.select_for_update()
                             .get_or_create(key=key,
                                            owner=owner,
                                            project=obj.project,
                                            history_type = history.type))

    notification.updated_datetime = timezone.now()
    notification.save()
    notification.history_entries.add(history)

    # Get a complete list of notifiable users for current
    # object and send the change notification to them.
    notify_users = get_users_to_notify(obj, discard_users=[notification.owner])
    for notify_user in notify_users:
        notification.notify_users.add(notify_user)

    # If we are the min interval is 0 it just work in a synchronous and spamming way
    if settings.CHANGE_NOTIFICATIONS_MIN_INTERVAL == 0:
        send_sync_notifications(notification.id)
开发者ID:AmiZya,项目名称:taiga-back,代码行数:25,代码来源:services.py


示例5: test_get_comment_versions

def test_get_comment_versions(client):
    project = f.create_project()
    us = f.create_userstory(project=project)
    f.MembershipFactory.create(project=project, user=project.owner, is_admin=True)
    key = make_key_from_model_object(us)
    history_entry = f.HistoryEntryFactory.create(
                             type=HistoryType.change,
                             comment="testing",
                             key=key,
                             diff={},
                             user={"pk": project.owner.id},
                             edit_comment_date=datetime.datetime.now(),
                             comment_versions = [{
                                "comment_html": "<p>test</p>",
                                "date": "2016-05-09T09:34:27.221Z",
                                "comment": "test",
                                "user": {
                                    "id": project.owner.id,
                                }}])

    client.login(project.owner)
    url = reverse("userstory-history-comment-versions", args=(us.id,))
    url = "%s?id=%s" % (url, history_entry.id)

    response = client.get(url, content_type="application/json")
    assert 200 == response.status_code, response.status_code
    assert response.data[0]["user"]["username"] == project.owner.username
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:27,代码来源:test_history.py


示例6: test_edit_comment

def test_edit_comment(client):
    project = f.create_project()
    us = f.create_userstory(project=project)
    f.MembershipFactory.create(project=project, user=project.owner, is_admin=True)
    key = make_key_from_model_object(us)
    history_entry = f.HistoryEntryFactory.create(type=HistoryType.change,
                                                 comment="testing",
                                                 key=key,
                                                 diff={},
                                                 user={"pk": project.owner.id})

    history_entry_created_at = history_entry.created_at
    assert history_entry.comment_versions == None
    assert history_entry.edit_comment_date == None

    client.login(project.owner)
    url = reverse("userstory-history-edit-comment", args=(us.id,))
    url = "%s?id=%s" % (url, history_entry.id)

    data = json.dumps({"comment": "testing update comment"})
    response = client.post(url, data, content_type="application/json")
    assert 200 == response.status_code, response.status_code


    history_entry = HistoryEntry.objects.get(id=history_entry.id)
    assert len(history_entry.comment_versions) == 1
    assert history_entry.comment == "testing update comment"
    assert history_entry.comment_versions[0]["comment"] == "testing"
    assert history_entry.edit_comment_date != None
    assert history_entry.comment_versions[0]["user"]["id"] == project.owner.id
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:30,代码来源:test_history.py


示例7: _import_action

    def _import_action(self, us, action, statuses, options):
        key = make_key_from_model_object(us)
        typename = get_typename_for_model_class(UserStory)
        action_data = self._transform_action_data(us, action, statuses, options)
        if action_data is None:
            return

        change_old = action_data['change_old']
        change_new = action_data['change_new']
        hist_type = action_data['hist_type']
        comment = action_data['comment']
        user = action_data['user']

        diff = make_diff_from_dicts(change_old, change_new)
        fdiff = FrozenDiff(key, diff, {})

        entry = HistoryEntry.objects.create(
            user=user,
            project_id=us.project.id,
            key=key,
            type=hist_type,
            snapshot=None,
            diff=fdiff.diff,
            values=make_diff_values(typename, fdiff),
            comment=comment,
            comment_html=mdrender(us.project, comment),
            is_hidden=False,
            is_snapshot=False,
        )
        HistoryEntry.objects.filter(id=entry.id).update(created_at=action['date'])
        return HistoryEntry.objects.get(id=entry.id)
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:31,代码来源:importer.py


示例8: _import_event

    def _import_event(self, obj, event, options, cumulative_data):
        typename = get_typename_for_model_class(type(obj))
        key = make_key_from_model_object(obj)
        event_data = self._transform_event_data(obj, event, options, cumulative_data)
        if event_data is None:
            return

        change_old = event_data['change_old']
        change_new = event_data['change_new']
        user = event_data['user']

        diff = make_diff_from_dicts(change_old, change_new)
        fdiff = FrozenDiff(key, diff, {})
        values = make_diff_values(typename, fdiff)
        values.update(event_data['update_values'])
        entry = HistoryEntry.objects.create(
            user=user,
            project_id=obj.project.id,
            key=key,
            type=HistoryType.change,
            snapshot=None,
            diff=fdiff.diff,
            values=values,
            comment="",
            comment_html="",
            is_hidden=False,
            is_snapshot=False,
        )
        HistoryEntry.objects.filter(id=entry.id).update(created_at=event['created_at'])
        return HistoryEntry.objects.get(id=entry.id)
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:30,代码来源:importer.py


示例9: store_history

def store_history(project, obj, history):
    serialized = serializers.HistoryExportSerializer(data=history, context={"project": project})
    if serialized.is_valid():
        serialized.object.key = make_key_from_model_object(obj)
        if serialized.object.diff is None:
            serialized.object.diff = []
        serialized.object._importing = True
        serialized.save()
        return serialized
    add_errors("history", serialized.errors)
    return serialized
开发者ID:SashaBorandi,项目名称:taiga-back,代码行数:11,代码来源:service.py


示例10: _store_history

def _store_history(project, obj, history):
    validator = validators.HistoryExportValidator(data=history, context={"project": project})
    if validator.is_valid():
        validator.object.key = make_key_from_model_object(obj)
        if validator.object.diff is None:
            validator.object.diff = []
        validator.object.project_id = project.id
        validator.object._importing = True
        validator.save()
        return validator
    add_errors("history", validator.errors)
    return validator
开发者ID:0-T-0,项目名称:taiga-back,代码行数:12,代码来源:store.py


示例11: data_us

def data_us(data):
    m = type("Models", (object,), {})
    m.public_user_story = f.UserStoryFactory(project=data.public_project, ref=1)
    m.public_history_entry = f.HistoryEntryFactory.create(type=HistoryType.change,
                                                          comment="testing public",
                                                          key=make_key_from_model_object(m.public_user_story),
                                                          diff={},
                                                          user={"pk": data.project_member_with_perms.pk})

    m.private_user_story1 = f.UserStoryFactory(project=data.private_project1, ref=5)
    m.private_history_entry1 = f.HistoryEntryFactory.create(type=HistoryType.change,
                                                          comment="testing 1",
                                                          key=make_key_from_model_object(m.private_user_story1),
                                                          diff={},
                                                          user={"pk": data.project_member_with_perms.pk})
    m.private_user_story2 = f.UserStoryFactory(project=data.private_project2, ref=9)
    m.private_history_entry2 = f.HistoryEntryFactory.create(type=HistoryType.change,
                                                          comment="testing 2",
                                                          key=make_key_from_model_object(m.private_user_story2),
                                                          diff={},
                                                          user={"pk": data.project_member_with_perms.pk})
    return m
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:22,代码来源:test_history_resources.py


示例12: test_delete_comment_by_project_owner

def test_delete_comment_by_project_owner(client):
    project = f.create_project()
    us = f.create_userstory(project=project)
    membership = f.MembershipFactory.create(project=project, user=project.owner, is_owner=True)
    key = make_key_from_model_object(us)
    history_entry = f.HistoryEntryFactory.create(type=HistoryType.change,
                                                                            comment="testing",
                                                                            key=key)

    client.login(project.owner)
    url = reverse("userstory-history-delete-comment", args=(us.id,))
    url = "%s?id=%s"%(url, history_entry.id)
    response = client.post(url, content_type="application/json")
    assert 200 == response.status_code, response.status_code
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:14,代码来源:test_history.py


示例13: test_get_comment_versions_from_history_entry_without_comment

def test_get_comment_versions_from_history_entry_without_comment(client):
    project = f.create_project()
    us = f.create_userstory(project=project)
    f.MembershipFactory.create(project=project, user=project.owner, is_admin=True)
    key = make_key_from_model_object(us)
    history_entry = f.HistoryEntryFactory.create(
                             type=HistoryType.change,
                             key=key,
                             diff={},
                             user={"pk": project.owner.id})

    client.login(project.owner)
    url = reverse("userstory-history-comment-versions", args=(us.id,))
    url = "%s?id=%s" % (url, history_entry.id)

    response = client.get(url, content_type="application/json")
    assert 200 == response.status_code, response.status_code
    assert response.data == None
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:18,代码来源:test_history.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python services.take_snapshot函数代码示例发布时间:2022-05-27
下一篇:
Python services.get_model_from_key函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap