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

Python services.take_snapshot函数代码示例

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

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



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

示例1: snapshot_issues_in_bulk

def snapshot_issues_in_bulk(bulk_data, user):
    for issue_data in bulk_data:
        try:
            issue = models.Issue.objects.get(pk=issue_data['issue_id'])
            take_snapshot(issue, user=user)
        except models.Issue.DoesNotExist:
            pass
开发者ID:taigaio,项目名称:taiga-back,代码行数:7,代码来源:services.py


示例2: snapshot_tasks_in_bulk

def snapshot_tasks_in_bulk(bulk_data, user):
    for task_data in bulk_data:
        try:
            task = models.Task.objects.get(pk=task_data['task_id'])
            take_snapshot(task, user=user)
        except models.Task.DoesNotExist:
            pass
开发者ID:aminadha,项目名称:taiga-back,代码行数:7,代码来源:services.py


示例3: snapshot_userstories_in_bulk

def snapshot_userstories_in_bulk(bulk_data, user):
    for us_data in bulk_data:
        try:
            us = models.UserStory.objects.get(pk=us_data['us_id'])
            take_snapshot(us, user=user)
        except models.UserStory.DoesNotExist:
            pass
开发者ID:CrypticGator,项目名称:taiga-back,代码行数:7,代码来源:services.py


示例4: test_issues_event_bad_comment

def test_issues_event_bad_comment(client):
    issue = f.IssueFactory.create(external_reference=["gitlab", "10"])
    take_snapshot(issue, user=issue.owner)

    payload = {
        "user": {
            "username": "test"
        },
        "issue": {
            "iid": "10",
            "title": "test-title",
        },
        "object_attributes": {
            "noteable_type": "Issue",
        },
        "repository": {
            "homepage": "test",
        },
    }
    ev_hook = event_hooks.IssueCommentEventHook(issue.project, payload)

    mail.outbox = []

    with pytest.raises(ActionSyntaxException) as excinfo:
        ev_hook.process_event()

    assert str(excinfo.value) == "Invalid issue comment information"

    assert Issue.objects.count() == 1
    assert len(mail.outbox) == 0
开发者ID:SKOx0,项目名称:taiga-back,代码行数:30,代码来源:test_hooks_gitlab.py


示例5: test_issues_event_bad_comment

def test_issues_event_bad_comment(client):
    issue = f.IssueFactory.create(external_reference=["bitbucket", "10"])
    take_snapshot(issue, user=issue.owner)

    payload = {
        "actor": {
            "user": {
                "uuid": "{ce1054cd-3f43-49dc-8aea-d3085ee7ec9b}",
                "username": "test-user",
                "links": {"html": {"href": "http://bitbucket.com/test-user"}}
            }
        },
        "issue": {
            "id": "10",
            "title": "test-title",
            "links": {"html": {"href": "http://bitbucket.com/site/master/issue/10"}},
            "content": {"raw": "test-content"}
        },
        "comment": {
        },
        "repository": {
            "links": {"html": {"href": "http://bitbucket.com/test-user/test-project"}}
        }
    }
    ev_hook = event_hooks.IssueCommentEventHook(issue.project, payload)

    mail.outbox = []

    with pytest.raises(ActionSyntaxException) as excinfo:
        ev_hook.process_event()

    assert str(excinfo.value) == "Invalid issue comment information"

    assert Issue.objects.count() == 1
    assert len(mail.outbox) == 0
开发者ID:74Labs,项目名称:taiga-back,代码行数:35,代码来源:test_hooks_bitbucket.py


示例6: test_create_task_timeline

def test_create_task_timeline():
    task = factories.TaskFactory.create(subject="test task timeline")
    history_services.take_snapshot(task, user=task.owner)
    project_timeline = service.get_project_timeline(task.project)
    assert project_timeline[0].event_type == "tasks.task.create"
    assert project_timeline[0].data["task"]["subject"] == "test task timeline"
    assert project_timeline[0].data["user"]["id"] == task.owner.id
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py


示例7: test_assigned_to_user_story_timeline

def test_assigned_to_user_story_timeline():
    membership = factories.MembershipFactory.create()
    user_story = factories.UserStoryFactory.create(subject="test us timeline", assigned_to=membership.user, project=membership.project)
    history_services.take_snapshot(user_story, user=user_story.owner)
    user_timeline = service.get_profile_timeline(user_story.assigned_to)
    assert user_timeline[0].event_type == "userstories.userstory.create"
    assert user_timeline[0].data["userstory"]["subject"] == "test us timeline"
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py


示例8: create_us

    def create_us(self, project, milestone=None, computable_project_roles=list(Role.objects.all())):
        us = UserStory.objects.create(subject=self.sd.choice(SUBJECT_CHOICES),
                                      project=project,
                                      owner=self.sd.db_object_from_queryset(
                                              project.memberships.filter(user__isnull=False)).user,
                                      description=self.sd.paragraph(),
                                      milestone=milestone,
                                      status=self.sd.db_object_from_queryset(project.us_statuses.filter(
                                                                             is_closed=False)),
                                      tags=self.sd.words(1, 3).split(" "))

        for role_points in us.role_points.filter(role__in=computable_project_roles):
            if milestone:
                role_points.points = self.sd.db_object_from_queryset(
                                us.project.points.exclude(value=None))
            else:
                role_points.points = self.sd.db_object_from_queryset(
                                              us.project.points.all())

            role_points.save()

        for i in range(self.sd.int(*NUM_ATTACHMENTS)):
            attachment = self.create_attachment(us, i+1)

        if self.sd.choice([True, True, False, True, True]):
            us.assigned_to = self.sd.db_object_from_queryset(project.memberships.filter(user__isnull=False)).user
            us.save()

        take_snapshot(us,
                      comment=self.sd.paragraph(),
                      user=us.owner)

        return us
开发者ID:6ft,项目名称:taiga-back,代码行数:33,代码来源:sample_data.py


示例9: create_bug

    def create_bug(self, project):
        bug = Issue.objects.create(project=project,
                                   subject=self.sd.choice(SUBJECT_CHOICES),
                                   description=self.sd.paragraph(),
                                   owner=self.sd.db_object_from_queryset(
                                            project.memberships.filter(user__isnull=False)).user,
                                   severity=self.sd.db_object_from_queryset(Severity.objects.filter(
                                                                                    project=project)),
                                   status=self.sd.db_object_from_queryset(IssueStatus.objects.filter(
                                                                                     project=project)),
                                   priority=self.sd.db_object_from_queryset(Priority.objects.filter(
                                                                                    project=project)),
                                   type=self.sd.db_object_from_queryset(IssueType.objects.filter(
                                                                                 project=project)),
                                   tags=self.sd.words(1, 10).split(" "))

        for i in range(self.sd.int(*NUM_ATTACHMENTS)):
            attachment = self.create_attachment(bug, i+1)

        if bug.status.order != 1:
            bug.assigned_to = self.sd.db_object_from_queryset(project.memberships.filter(
                                                                      user__isnull=False)).user
            bug.save()

        take_snapshot(bug,
                      comment=self.sd.paragraph(),
                      user=bug.owner)

        return bug
开发者ID:6ft,项目名称:taiga-back,代码行数:29,代码来源:sample_data.py


示例10: create_task

    def create_task(self, project, milestone, us, min_date, max_date, closed=False):
        task = Task(subject=self.sd.choice(SUBJECT_CHOICES),
                    description=self.sd.paragraph(),
                    project=project,
                    owner=self.sd.db_object_from_queryset(project.memberships.filter(user__isnull=False)).user,
                    milestone=milestone,
                    user_story=us,
                    finished_date=None,
                    assigned_to = self.sd.db_object_from_queryset(
                    project.memberships.filter(user__isnull=False)).user,
                    tags=self.sd.words(1, 10).split(" "))

        if closed:
            task.status = project.task_statuses.get(order=4)
        else:
            task.status = self.sd.db_object_from_queryset(project.task_statuses.all())

        if task.status.is_closed:
            task.finished_date = self.sd.datetime_between(min_date, max_date)

        task.save()

        for i in range(self.sd.int(*NUM_ATTACHMENTS)):
            attachment = self.create_attachment(task, i+1)

        take_snapshot(task,
                      comment=self.sd.paragraph(),
                      user=task.owner)

        return task
开发者ID:6ft,项目名称:taiga-back,代码行数:30,代码来源:sample_data.py


示例11: test_webhooks_when_update_epic_related_userstory

def test_webhooks_when_update_epic_related_userstory(settings):
    settings.WEBHOOKS_ENABLED = True
    project = f.ProjectFactory()
    f.WebhookFactory.create(project=project)
    f.WebhookFactory.create(project=project)

    epic = f.EpicFactory.create(project=project)
    obj = f.RelatedUserStory.create(epic=epic, order=33)

    with patch('taiga.webhooks.tasks._send_request') as send_request_mock:
        services.take_snapshot(obj, user=epic.owner)
        assert send_request_mock.call_count == 2

    obj.order = 66
    obj.save()

    with patch('taiga.webhooks.tasks._send_request') as send_request_mock:
        services.take_snapshot(obj, user=epic.owner)
        assert send_request_mock.call_count == 2

        (webhook_id, url, key, data) = send_request_mock.call_args[0]
        assert data["action"] == "change"
        assert data["type"] == "relateduserstory"
        assert data["by"]["id"] == epic.owner.id
        assert "date" in data
        assert data["data"]["id"] == obj.id
        assert data["data"]["order"] == obj.order
        assert data["change"]["diff"]["order"]["to"] == 66
        assert data["change"]["diff"]["order"]["from"] == 33
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:29,代码来源:test_webhooks_epics.py


示例12: _process_opened

    def _process_opened(self, number, subject, github_url, user, github_user_name, github_user_url, project_url, description):
        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=description,
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=['github', github_url],
            owner=user
        )
        take_snapshot(issue, user=user)

        if number and subject and github_user_name and github_user_url:
            comment = _("Issue created by [@{github_user_name}]({github_user_url} "
                        "\"See @{github_user_name}'s GitHub profile\") "
                        "from GitHub.\nOrigin GitHub issue: [gh#{number} - {subject}]({github_url} "
                        "\"Go to 'gh#{number} - {subject}'\"):\n\n"
                        "{description}").format(github_user_name=github_user_name,
                                                github_user_url=github_user_url,
                                                number=number,
                                                subject=subject,
                                                github_url=github_url,
                                                description=description)
        else:
            comment = _("Issue created from GitHub.")

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
开发者ID:alvarollmenezes,项目名称:taiga-back,代码行数:30,代码来源:event_hooks.py


示例13: process_event

    def process_event(self):
        if self.ignore():
            return

        data = self.get_data()

        if not all([data['subject'], data['url']]):
            raise ActionSyntaxException(_("Invalid issue information"))

        user = self.get_user(data['user_id'], self.platform_slug)

        issue = Issue.objects.create(
            project=self.project,
            subject=data['subject'],
            description=data['description'],
            status=self.project.default_issue_status,
            type=self.project.default_issue_type,
            severity=self.project.default_severity,
            priority=self.project.default_priority,
            external_reference=[self.platform_slug, data['url']],
            owner=user
        )
        take_snapshot(issue, user=user)

        comment = self.generate_new_issue_comment(**data)

        snapshot = take_snapshot(issue, comment=comment, user=user)
        send_notifications(issue, history=snapshot)
开发者ID:0-T-0,项目名称:taiga-back,代码行数:28,代码来源:event_hooks.py


示例14: test_create_user_story_timeline

def test_create_user_story_timeline():
    user_story = factories.UserStoryFactory.create(subject="test us timeline")
    history_services.take_snapshot(user_story, user=user_story.owner)
    project_timeline = service.get_project_timeline(user_story.project)
    assert project_timeline[0].event_type == "userstories.userstory.create"
    assert project_timeline[0].data["userstory"]["subject"] == "test us timeline"
    assert project_timeline[0].data["user"]["id"] == user_story.owner.id
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py


示例15: test_send_request_one_webhook_signal

def test_send_request_one_webhook_signal(settings):
    settings.WEBHOOKS_ENABLED = True
    project = f.ProjectFactory()
    f.WebhookFactory.create(project=project)

    objects = [
        f.IssueFactory.create(project=project),
        f.TaskFactory.create(project=project),
        f.UserStoryFactory.create(project=project),
        f.WikiPageFactory.create(project=project)
    ]

    response = Mock(status_code=200, headers={}, text="ok")
    response.elapsed.total_seconds.return_value = 100

    for obj in objects:
        with patch("taiga.webhooks.tasks.requests.Session.send", return_value=response) as session_send_mock, \
         patch("taiga.base.utils.urls.validate_private_url", return_value=True):
            services.take_snapshot(obj, user=obj.owner, comment="test")
            assert session_send_mock.call_count == 1

    for obj in objects:
        with patch("taiga.webhooks.tasks.requests.Session.send", return_value=response) as session_send_mock, \
         patch("taiga.base.utils.urls.validate_private_url", return_value=True):
            services.take_snapshot(obj, user=obj.owner, comment="test", delete=True)
            assert session_send_mock.call_count == 1
开发者ID:taigaio,项目名称:taiga-back,代码行数:26,代码来源:test_webhooks_signals.py


示例16: test_create_issue_timeline

def test_create_issue_timeline():
    issue = factories.IssueFactory.create(subject="test issue timeline")
    history_services.take_snapshot(issue, user=issue.owner)
    project_timeline = service.get_project_timeline(issue.project)
    assert project_timeline[0].event_type == "issues.issue.create"
    assert project_timeline[0].data["issue"]["subject"] == "test issue timeline"
    assert project_timeline[0].data["user"]["id"] == issue.owner.id
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py


示例17: test_create_wiki_page_timeline

def test_create_wiki_page_timeline():
    page = factories.WikiPageFactory.create(slug="test wiki page timeline")
    history_services.take_snapshot(page, user=page.owner)
    project_timeline = service.get_project_timeline(page.project)
    assert project_timeline[0].event_type == "wiki.wikipage.create"
    assert project_timeline[0].data["wikipage"]["slug"] == "test wiki page timeline"
    assert project_timeline[0].data["user"]["id"] == page.owner.id
开发者ID:cubettech,项目名称:taiga-back,代码行数:7,代码来源:test_timeline.py


示例18: create_project

    def create_project(self, counter, is_private=None, blocked_code=None):
        if is_private is None:
            is_private=self.sd.boolean()

        anon_permissions = not is_private and list(map(lambda perm: perm[0], ANON_PERMISSIONS)) or []
        public_permissions = not is_private and list(map(lambda perm: perm[0], ANON_PERMISSIONS)) or []
        project = Project.objects.create(slug='project-%s'%(counter),
                                         name='Project Example {0}'.format(counter),
                                         description='Project example {0} description'.format(counter),
                                         owner=self.sd.choice(self.users),
                                         is_private=is_private,
                                         anon_permissions=anon_permissions,
                                         public_permissions=public_permissions,
                                         total_story_points=self.sd.int(600, 3000),
                                         total_milestones=self.sd.int(5,10),
                                         tags=self.sd.words(1, 10).split(" "),
                                         blocked_code=blocked_code)

        project.is_looking_for_people = counter in LOOKING_FOR_PEOPLE_PROJECTS_POSITIONS
        if project.is_looking_for_people:
            project.looking_for_people_note = self.sd.short_sentence()
        project.is_featured = counter in FEATURED_PROJECTS_POSITIONS
        project.is_kanban_activated = True
        project.is_epics_activated = True
        project.save()
        take_snapshot(project, user=project.owner)

        self.create_likes(project)
        self.create_watchers(project, NotifyLevel.involved)

        return project
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:31,代码来源:sample_data.py


示例19: _import_user_stories_data

    def _import_user_stories_data(self, project, repo, options):
        users_bindings = options.get('users_bindings', {})

        page = 1
        while True:
            issues = self._client.get("/repos/{}/issues".format(repo['full_name']), {
                "state": "all",
                "sort": "created",
                "direction": "asc",
                "page": page,
                "per_page": 100
            })
            page += 1
            for issue in issues:
                tags = []
                for label in issue['labels']:
                    tags.append(label['name'].lower())

                assigned_to = users_bindings.get(issue['assignee']['id'] if issue['assignee'] else None, None)

                external_reference = None
                if options.get('keep_external_reference', False):
                    external_reference = ["github", issue['html_url']]

                us = UserStory.objects.create(
                    ref=issue['number'],
                    project=project,
                    owner=users_bindings.get(issue['user']['id'], self._user),
                    milestone=project.milestones.get(name=issue['milestone']['title']) if issue['milestone'] else None,
                    assigned_to=assigned_to,
                    status=project.us_statuses.get(slug=issue['state']),
                    kanban_order=issue['number'],
                    sprint_order=issue['number'],
                    backlog_order=issue['number'],
                    subject=issue['title'],
                    description=issue.get("body", "") or "",
                    tags=tags,
                    external_reference=external_reference,
                    modified_date=issue['updated_at'],
                    created_date=issue['created_at'],
                )

                assignees = issue.get('assignees', [])
                if len(assignees) > 1:
                    for assignee in assignees:
                        if assignee['id'] != issue.get('assignee', {}).get('id', None):
                            assignee_user = users_bindings.get(assignee['id'], None)
                            if assignee_user is not None:
                                us.add_watcher(assignee_user)

                UserStory.objects.filter(id=us.id).update(
                    ref=issue['number'],
                    modified_date=issue['updated_at'],
                    created_date=issue['created_at']
                )

                take_snapshot(us, comment="", user=None, delete=False)

            if len(issues) < 100:
                break
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:60,代码来源:importer.py


示例20: store_wiki_page

def store_wiki_page(project, wiki_page):
    wiki_page["slug"] = slugify(unidecode(wiki_page.get("slug", "")))
    validator = validators.WikiPageExportValidator(data=wiki_page)
    if validator.is_valid():
        validator.object.project = project
        if validator.object.owner is None:
            validator.object.owner = validator.object.project.owner
        validator.object._importing = True
        validator.object._not_notify = True
        validator.save()
        validator.save_watchers()

        for attachment in wiki_page.get("attachments", []):
            _store_attachment(project, validator.object, attachment)

        history_entries = wiki_page.get("history", [])
        for history in history_entries:
            _store_history(project, validator.object, history)

        if not history_entries:
            take_snapshot(validator.object, user=validator.object.owner)

        return validator

    add_errors("wiki_pages", validator.errors)
    return None
开发者ID:0-T-0,项目名称:taiga-back,代码行数:26,代码来源:store.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python services.add_watcher函数代码示例发布时间:2022-05-27
下一篇:
Python services.make_key_from_model_object函数代码示例发布时间: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