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


Python services.send_notifications函数代码示例

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


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

示例1: _change_status

    def _change_status(self, ref, status_slug, gitlab_user):
        if Issue.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Issue
            statusClass = IssueStatus
        elif Task.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Task
            statusClass = TaskStatus
        elif UserStory.objects.filter(project=self.project, ref=ref).exists():
            modelClass = UserStory
            statusClass = UserStoryStatus
        else:
            raise ActionSyntaxException(_("The referenced element doesn't exist"))

        element = modelClass.objects.get(project=self.project, ref=ref)

        try:
            status = statusClass.objects.get(project=self.project, slug=status_slug)
        except statusClass.DoesNotExist:
            raise ActionSyntaxException(_("The status doesn't exist"))

        element.status = status
        element.save()

        snapshot = take_snapshot(element,
                                 comment=_("Status changed from GitLab commit"),
                                 user=get_gitlab_user(gitlab_user))
        send_notifications(element, history=snapshot)
开发者ID:vuchau,项目名称:taiga-back,代码行数:27,代码来源:event_hooks.py

示例2: 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

示例3: process_event

    def process_event(self):
        if self.payload.get('object_attributes', {}).get("action", "") != "open":
            return

        subject = self.payload.get('object_attributes', {}).get('title', None)
        description = self.payload.get('object_attributes', {}).get('description', None)
        gitlab_reference = self.payload.get('object_attributes', {}).get('url', None)

        project_url = None
        if gitlab_reference:
            project_url = os.path.basename(os.path.basename(gitlab_reference))

        if not all([subject, gitlab_reference, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=replace_gitlab_references(project_url, 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=['gitlab', gitlab_reference],
            owner=get_gitlab_user(None)
        )
        take_snapshot(issue, user=get_gitlab_user(None))

        snapshot = take_snapshot(issue, comment=_("Created from GitLab"), user=get_gitlab_user(None))
        send_notifications(issue, history=snapshot)
开发者ID:vuchau,项目名称:taiga-back,代码行数:30,代码来源:event_hooks.py

示例4: process_event

    def process_event(self):
        if self.payload.get('action', None) != "opened":
            return

        subject = self.payload.get('issue', {}).get('title', None)
        description = self.payload.get('issue', {}).get('body', None)
        github_url = self.payload.get('issue', {}).get('html_url', None)
        github_user = self.payload.get('issue', {}).get('user', {}).get('id', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)

        if not all([subject, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        issue = Issue.objects.create(
            project=self.project,
            subject=subject,
            description=replace_github_references(project_url, 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=get_github_user(github_user)
        )
        take_snapshot(issue, user=get_github_user(github_user))

        snapshot = take_snapshot(issue, comment=_("Created from GitHub"), user=get_github_user(github_user))
        send_notifications(issue, history=snapshot)
开发者ID:benzaku,项目名称:taiga-back,代码行数:28,代码来源:event_hooks.py

示例5: send_notifications

    def send_notifications(self, obj, history=None):
        """
        Shortcut method for resources with special save
        cases on actions methods that not uses standard
        `post_save` hook of drf resources.
        """
        if history is None:
            history = self.get_last_history()

        # If not history found, or it is empty. Do notthing.
        if not history:
            return

        if self._not_notify:
            return

        obj = self.get_object_for_snapshot(obj)

        # Process that analizes the corresponding diff and
        # some text fields for extract mentions and add them
        # to watchers before obtain a complete list of
        # notifiable users.
        services.analize_object_for_watchers(obj, history.comment, history.owner)

        # Get a complete list of notifiable users for current
        # object and send the change notification to them.
        services.send_notifications(obj, history=history)
开发者ID:heyox,项目名称:taiga-back,代码行数:27,代码来源:mixins.py

示例6: _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

示例7: _process_commit

    def _process_commit(self, ref, status_slug, commit):
        element = get_element_from_ref(self.project, ref)
        status = get_status_from_slug(self.project, element, status_slug)
        element.status = status
        element.save()

        commit_id = commit.get("id", None)
        commit_url = commit.get("url", None)
        # @todo replace_gitlab_references()?
        commit_message = commit.get("message").strip()
        author_info = self.get_user_info_from_payload(commit)
        author_user = author_info.get('user')

        """ Do we care about pushed by vs authored by?
        if author_info.get('email') != self.pusher.get('email'):
            if self.pusher.get('user') is not None:
                user = self.pusher.get('user')
                pushed_by = _(" (Pushed by @{pusher_username})").format(
                    pusher_username=user.get_username()
                )
            else:
                pushed_by = _(" (Pushed by [{pusher_username}](mailto:{pusher_url}))").format(
                    pusher_username=self.pusher.get('name'),
                    pusher_url=self.pusher.get('email')
                )
        else:
            pushed_by = ""
        """

        if not all([commit_id, commit_url]):
            raise ActionSyntaxException(_("Invalid commit information"))

        # we can use a real user
        if author_user is not None and not author_user.is_system:
            comment = _(self.messages.get('native').get('push')).format(
                username=author_user.username,
                service_type=self.service_type,
                status=status.name,
                commit_id=commit_id[:7],
                commit_url=commit_url,
                commit_message=commit_message)

        # use what info we have
        elif "name" in author_info and "email" in author_info:
            comment = _(self.messages.get('system').get('push')).format(
                name=author_info.get("name'"),
                service_type=self.service_type,
                status=status.name,
                user_url=author_info.get("url"),
                commit_id=str(commit_id)[:7],
                commit_url=commit_url,
                commit_message=commit_message)

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

示例8: _process_status_changed

    def _process_status_changed(self, github_url, user, status):
        issues = Issue.objects.filter(external_reference=["github", github_url])

        for issue in list(issues):
            issue.status = IssueStatus.objects.get(project=self.project, slug=status)
            issue.save()

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

示例9: _process_edited

    def _process_edited(self, subject, github_url, user, description):
        issues = Issue.objects.filter(external_reference=["github", github_url])

        for issue in list(issues):
            issue.subject = subject
            issue.description = description
            issue.save()

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

示例10: _change_status

    def _change_status(self, ref, status_slug, github_user, commit):
        if Issue.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Issue
            statusClass = IssueStatus
        elif Task.objects.filter(project=self.project, ref=ref).exists():
            modelClass = Task
            statusClass = TaskStatus
        elif UserStory.objects.filter(project=self.project, ref=ref).exists():
            modelClass = UserStory
            statusClass = UserStoryStatus
        else:
            raise ActionSyntaxException(_("The referenced element doesn't exist"))

        element = modelClass.objects.get(project=self.project, ref=ref)

        try:
            status = statusClass.objects.get(project=self.project, slug=status_slug)
        except statusClass.DoesNotExist:
            raise ActionSyntaxException(_("The status doesn't exist"))

        element.status = status
        element.save()

        github_user_id = github_user.get('id', None)
        github_user_name = github_user.get('login', None)
        github_user_url = github_user.get('html_url', None)
        commit_id = commit.get("id", None)
        commit_url = commit.get("url", None)
        commit_message = commit.get("message", None)

        if (github_user_id and github_user_name and github_user_url and
                commit_id and commit_url and commit_message):
            comment = _("Status changed by [@{github_user_name}]({github_user_url} "
                        "\"See @{github_user_name}'s GitHub profile\") "
                        "from GitHub commit [{commit_id}]({commit_url} "
                        "\"See commit '{commit_id} - {commit_message}'\").").format(
                                                               github_user_name=github_user_name,
                                                               github_user_url=github_user_url,
                                                               commit_id=commit_id[:7],
                                                               commit_url=commit_url,
                                                               commit_message=commit_message)

        else:
            comment = _("Status changed from GitHub commit.")

        snapshot = take_snapshot(element,
                                 comment=comment,
                                 user=get_github_user(github_user_id))
        send_notifications(element, history=snapshot)
开发者ID:74Labs,项目名称:taiga-back,代码行数:49,代码来源:event_hooks.py

示例11: process_event

    def process_event(self):
        number = self.payload.get('issue', {}).get('id', None)
        subject = self.payload.get('issue', {}).get('title', None)

        bitbucket_url = self.payload.get('issue', {}).get('links', {}).get('html', {}).get('href', None)

        bitbucket_user_id = self.payload.get('actor', {}).get('user', {}).get('uuid', None)
        bitbucket_user_name = self.payload.get('actor', {}).get('user', {}).get('username', None)
        bitbucket_user_url = self.payload.get('actor', {}).get('user', {}).get('links', {}).get('html', {}).get('href')

        project_url = self.payload.get('repository', {}).get('links', {}).get('html', {}).get('href', None)

        description = self.payload.get('issue', {}).get('content', {}).get('raw', '')
        description = replace_bitbucket_references(project_url, description)

        user = get_bitbucket_user(bitbucket_user_id)

        if not all([subject, bitbucket_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        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=['bitbucket', bitbucket_url],
            owner=user
        )
        take_snapshot(issue, user=user)

        if number and subject and bitbucket_user_name and bitbucket_user_url:
            comment = _("Issue created by [@{bitbucket_user_name}]({bitbucket_user_url} "
                        "\"See @{bitbucket_user_name}'s BitBucket profile\") "
                        "from BitBucket.\nOrigin BitBucket issue: [bb#{number} - {subject}]({bitbucket_url} "
                        "\"Go to 'bb#{number} - {subject}'\"):\n\n"
                        "{description}").format(bitbucket_user_name=bitbucket_user_name,
                                                bitbucket_user_url=bitbucket_user_url,
                                                number=number,
                                                subject=subject,
                                                bitbucket_url=bitbucket_url,
                                                description=description)
        else:
            comment = _("Issue created from BitBucket.")

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

示例12: process_event

    def process_event(self):
        if self.payload.get('action', None) != "opened":
            return

        number = self.payload.get('issue', {}).get('number', None)
        subject = self.payload.get('issue', {}).get('title', None)
        github_url = self.payload.get('issue', {}).get('html_url', None)
        github_user_id = self.payload.get('issue', {}).get('user', {}).get('id', None)
        github_user_name = self.payload.get('issue', {}).get('user', {}).get('login', None)
        github_user_url = self.payload.get('issue', {}).get('user', {}).get('html_url', None)
        project_url = self.payload.get('repository', {}).get('html_url', None)
        description = self.payload.get('issue', {}).get('body', None)
        description = replace_github_references(project_url, description)

        user = get_github_user(github_user_id)

        if not all([subject, github_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue information"))

        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:74Labs,项目名称:taiga-back,代码行数:48,代码来源:event_hooks.py

示例13: _process_label_changed

    def _process_label_changed(self, user, github_url):
        issues = Issue.objects.filter(external_reference=["github", github_url])
        
        l = self.payload.get('issue', {}).get('labels', [])
        labels = [x['name'] for x in l]

        issueType = IssueType.objects.filter(project=self.project, name__in=labels).order_by('order').first()

        for issue in list(issues):
            issue.tags = labels 
            issue.type = issueType
            issue.save()

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

示例14: process_event

    def process_event(self):
        attrs = self.payload.get('object_attributes', {})

        if attrs.get("noteable_type", None) != "Issue":
            return

        number = self.payload.get('issue', {}).get('iid', None)
        subject = self.payload.get('issue', {}).get('title', None)

        project_url = self.payload.get('repository', {}).get('homepage', None)

        gitlab_url = os.path.join(project_url, "issues", str(number))
        gitlab_user_name = self.payload.get('user', {}).get('username', None)
        gitlab_user_url = os.path.join(os.path.dirname(os.path.dirname(project_url)), "u", gitlab_user_name)

        comment_message = attrs.get('note', None)
        comment_message = replace_gitlab_references(project_url, comment_message)

        user = get_gitlab_user(None)

        if not all([comment_message, gitlab_url, project_url]):
            raise ActionSyntaxException(_("Invalid issue comment information"))

        issues = Issue.objects.filter(external_reference=["gitlab", gitlab_url])
        tasks = Task.objects.filter(external_reference=["gitlab", gitlab_url])
        uss = UserStory.objects.filter(external_reference=["gitlab", gitlab_url])

        for item in list(issues) + list(tasks) + list(uss):
            if number and subject and gitlab_user_name and gitlab_user_url:
                comment = _("Comment by [@{gitlab_user_name}]({gitlab_user_url} "
                            "\"See @{gitlab_user_name}'s GitLab profile\") "
                            "from GitLab.\nOrigin GitLab issue: [gl#{number} - {subject}]({gitlab_url} "
                            "\"Go to 'gl#{number} - {subject}'\")\n\n"
                            "{message}").format(gitlab_user_name=gitlab_user_name,
                                                gitlab_user_url=gitlab_user_url,
                                                number=number,
                                                subject=subject,
                                                gitlab_url=gitlab_url,
                                                message=comment_message)
            else:
                comment = _("Comment From GitLab:\n\n{message}").format(message=comment_message)

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

示例15: _create_wiki_page_when_create_wiki_link_if_not_exist

    def _create_wiki_page_when_create_wiki_link_if_not_exist(self, request, wiki_link):
        try:
            self.check_permissions(request, "create_wiki_page", wiki_link)
        except exc.PermissionDenied:
            # Create only the wiki link because the user doesn't have permission.
            pass
        else:
            # Create the wiki link and the wiki page if not exist.
            wiki_page, created = models.WikiPage.objects.get_or_create(
                slug=wiki_link.href,
                project=wiki_link.project,
                defaults={"owner": self.request.user, "last_modifier": self.request.user})

            if created:
                # Creaste the new history entre, sSet watcher for the new wiki page
                # and send notifications about the new page created
                history = take_snapshot(wiki_page, user=self.request.user)
                analize_object_for_watchers(wiki_page, history.comment, history.owner)
                send_notifications(wiki_page, history=history)
开发者ID:shreeshreee,项目名称:taiga-back,代码行数:19,代码来源:api.py


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