示例#1
0
    def get(self, request):
        org = Organization(
            id=1,
            slug='organization',
            name='My Company',
        )
        team = Team(
            id=1,
            slug='team',
            name='My Team',
            organization=org,
        )
        project = Project(
            id=1,
            organization=org,
            team=team,
            slug='project',
            name='My Project',
        )
        release = Release(project=project,
                          organization_id=project.organization_id,
                          version='6c998f755f304593a4713abd123eaf8833a2de5e',
                          date_added=datetime(2016,
                                              10,
                                              12,
                                              15,
                                              39,
                                              tzinfo=pytz.utc))

        release_link = absolute_uri('/{}/{}/releases/{}/'.format(
            org.slug,
            project.slug,
            release.version,
        ))

        project_link = absolute_uri('/{}/{}/'.format(
            org.slug,
            project.slug,
        ))

        commit_list = [
            Commit(key='48b86fcd677da3dba5679d7a738240ce6fb74b20'),
            Commit(key='a53a2756bb8d111b43196210b34df90b87ed336b',
                   message='Update README.rst',
                   author=CommitAuthor(
                       name='David Cramer',
                       email='*****@*****.**',
                   )),
        ]

        return MailPreview(
            html_template='sentry/emails/activity/release.html',
            text_template='sentry/emails/activity/release.txt',
            context={
                'release':
                release,
                'project':
                project,
                'release_link':
                release_link,
                'project_link':
                project_link,
                'commit_list':
                commit_list,
                'reason':
                GroupSubscriptionReason.descriptions[
                    GroupSubscriptionReason.committed],
            },
        ).render(request)
    def get(self, request):
        org = Organization(
            id=1,
            slug='organization',
            name='My Company',
        )
        projects = [
            Project(
                id=1,
                organization=org,
                slug='project',
                name='My Project',
            ),
            Project(
                id=2,
                organization=org,
                slug='another-project',
                name='Another Project',
            ),
            Project(
                id=3,
                organization=org,
                slug='yet-another-project',
                name='Yet Another Project',
            ),
        ]
        release = Release(organization_id=org.id,
                          version='6c998f755f304593a4713abd123eaf8833a2de5e',
                          date_added=datetime.datetime(2016,
                                                       10,
                                                       12,
                                                       15,
                                                       39,
                                                       tzinfo=pytz.utc))

        deploy = Deploy(
            release=release,
            organization_id=org.id,
            environment_id=1,
            date_finished=datetime.datetime(2016,
                                            10,
                                            12,
                                            15,
                                            39,
                                            tzinfo=pytz.utc),
        )

        has_new_links = features.has('organizations:sentry10', org)
        if has_new_links:
            release_links = [
                absolute_uri(
                    u'/organizations/{}/releases/{}/?project={}'.format(
                        org.slug,
                        release.version,
                        p.id,
                    )) for p in projects
            ]
        else:
            release_links = [
                absolute_uri(u'/{}/{}/releases/{}/'.format(
                    org.slug,
                    p.slug,
                    release.version,
                )) for p in projects
            ]

        repos = [{
            'name':
            'getsentry/getsentry',
            'commits': [
                (Commit(
                    key='48b86fcd677da3dba5679d7a738240ce6fb74b20',
                    date_added=datetime.datetime(2016,
                                                 10,
                                                 11,
                                                 15,
                                                 39,
                                                 tzinfo=pytz.utc),
                ), None),
                (Commit(
                    key='a53a2756bb8d111b43196210b34df90b87ed336b',
                    message='Fix billing',
                    author=CommitAuthor(
                        name='David Cramer',
                        email='*****@*****.**',
                    ),
                    date_added=datetime.datetime(2016,
                                                 10,
                                                 11,
                                                 16,
                                                 45,
                                                 tzinfo=pytz.utc),
                ), User(email='*****@*****.**', name='David Cramer')),
            ],
        }, {
            'name':
            'getsentry/sentry',
            'commits': [
                (Commit(
                    key='3c8eb3b4af6ee2a29c68daa188fc730c8e4b39fd',
                    date_added=datetime.datetime(2016,
                                                 10,
                                                 10,
                                                 15,
                                                 39,
                                                 tzinfo=pytz.utc),
                ), None),
                (Commit(
                    key='373562702009df1692da6eb80a933139f29e094b',
                    message='Fix padding',
                    author=CommitAuthor(
                        name='Chris Jennings',
                        email='*****@*****.**',
                    ),
                    date_added=datetime.datetime(2016,
                                                 10,
                                                 10,
                                                 16,
                                                 39,
                                                 tzinfo=pytz.utc),
                ), None),
                (Commit(
                    key='631cd9096bd9811a046a472bb0aa8b573e86e1f1',
                    message='Update README.rst',
                    author=CommitAuthor(
                        name='David Cramer',
                        email='*****@*****.**',
                    ),
                    date_added=datetime.datetime(2016,
                                                 10,
                                                 11,
                                                 10,
                                                 39,
                                                 tzinfo=pytz.utc),
                ), User(email='*****@*****.**', name='David Cramer')),
            ],
        }]

        return MailPreview(
            html_template='sentry/emails/activity/release.html',
            text_template='sentry/emails/activity/release.txt',
            context={
                'release':
                release,
                'projects':
                zip(projects, release_links, [6, 1, 0]),
                'repos':
                repos,
                'reason':
                GroupSubscriptionReason.descriptions[
                    GroupSubscriptionReason.committed],
                'project_count':
                len(projects),
                'commit_count':
                4,
                'author_count':
                1,
                'file_count':
                5,
                'environment':
                'production',
                'deploy':
                deploy,
                'setup_repo_link':
                absolute_uri('/organizations/{}/repos/'.format(org.slug, )),
            },
        ).render(request)
示例#3
0
    def get(self, request):
        org = Organization(id=1, slug="organization", name="My Company")
        projects = [
            Project(id=1, organization=org, slug="project", name="My Project"),
            Project(id=2,
                    organization=org,
                    slug="another-project",
                    name="Another Project"),
            Project(id=3,
                    organization=org,
                    slug="yet-another-project",
                    name="Yet Another Project"),
        ]
        release = Release(
            organization_id=org.id,
            version="6c998f755f304593a4713abd123eaf8833a2de5e",
            date_added=datetime.datetime(2016, 10, 12, 15, 39,
                                         tzinfo=pytz.utc),
        )

        deploy = Deploy(
            release=release,
            organization_id=org.id,
            environment_id=1,
            date_finished=datetime.datetime(2016,
                                            10,
                                            12,
                                            15,
                                            39,
                                            tzinfo=pytz.utc),
        )

        release_links = [
            absolute_uri("/organizations/{}/releases/{}/?project={}".format(
                org.slug, release.version, p.id)) for p in projects
        ]

        repos = [
            {
                "name":
                "getsentry/getsentry",
                "commits": [
                    (
                        Commit(
                            key="48b86fcd677da3dba5679d7a738240ce6fb74b20",
                            date_added=datetime.datetime(2016,
                                                         10,
                                                         11,
                                                         15,
                                                         39,
                                                         tzinfo=pytz.utc),
                        ),
                        None,
                    ),
                    (
                        Commit(
                            key="a53a2756bb8d111b43196210b34df90b87ed336b",
                            message="Fix billing",
                            author=CommitAuthor(name="David Cramer",
                                                email="*****@*****.**"),
                            date_added=datetime.datetime(2016,
                                                         10,
                                                         11,
                                                         16,
                                                         45,
                                                         tzinfo=pytz.utc),
                        ),
                        User(email="*****@*****.**", name="David Cramer"),
                    ),
                ],
            },
            {
                "name":
                "getsentry/sentry",
                "commits": [
                    (
                        Commit(
                            key="3c8eb3b4af6ee2a29c68daa188fc730c8e4b39fd",
                            date_added=datetime.datetime(2016,
                                                         10,
                                                         10,
                                                         15,
                                                         39,
                                                         tzinfo=pytz.utc),
                        ),
                        None,
                    ),
                    (
                        Commit(
                            key="373562702009df1692da6eb80a933139f29e094b",
                            message="Fix padding",
                            author=CommitAuthor(name="Chris Jennings",
                                                email="*****@*****.**"),
                            date_added=datetime.datetime(2016,
                                                         10,
                                                         10,
                                                         16,
                                                         39,
                                                         tzinfo=pytz.utc),
                        ),
                        None,
                    ),
                    (
                        Commit(
                            key="631cd9096bd9811a046a472bb0aa8b573e86e1f1",
                            message="Update README.rst",
                            author=CommitAuthor(name="David Cramer",
                                                email="*****@*****.**"),
                            date_added=datetime.datetime(2016,
                                                         10,
                                                         11,
                                                         10,
                                                         39,
                                                         tzinfo=pytz.utc),
                        ),
                        User(email="*****@*****.**", name="David Cramer"),
                    ),
                ],
            },
        ]

        return MailPreview(
            html_template="sentry/emails/activity/release.html",
            text_template="sentry/emails/activity/release.txt",
            context={
                "release":
                release,
                "projects":
                zip(projects, release_links, [6, 1, 0]),
                "repos":
                repos,
                "reason":
                GroupSubscriptionReason.descriptions[
                    GroupSubscriptionReason.committed],
                "project_count":
                len(projects),
                "commit_count":
                4,
                "author_count":
                1,
                "file_count":
                5,
                "environment":
                "production",
                "deploy":
                deploy,
                "setup_repo_link":
                absolute_uri("/organizations/{}/repos/".format(org.slug)),
            },
        ).render(request)