Example #1
0
    def ticket_completed(self, request):
        email = self.data['email']
        logger.info("New registration with email %s", email)

        # Post message to internal slack notification channel
        internal_slack = get_slack_connection('djangoconeu')
        internal_slack.chat.post_message(
            channel='#notifications',
            text="%(name)s registered a %(release_title)s (reference: %(reference)s) :tada:" % self.data,
            username="******",
            icon_emoji=":ticket:",
        )

        # Invite to public slack
        if 'organizer' in self.data['release_title'].lower():  # TODO: remove when live
            public_slack = get_slack_connection('djangoconeu-attendees')
            existing_users = get_user_emails(public_slack)
            # TODO: remove the second part when this goes really live
            if email not in existing_users:
                public_slack.users.invite(
                    email=self.data['email'],
                    first_name=self.data['first_name'],
                    last_name=self.data['last_name'],
                )

        return self.ok(request)
Example #2
0
    def ticket_completed(self, request):
        email = self.data['email']
        logger.info("New registration with email %s", email)

        # Post message to internal slack notification channel
        internal_slack = get_slack_connection('djangoconeu')
        internal_slack.chat.post_message(
            channel='#notifications',
            text=
            "%(name)s registered a %(release_title)s (reference: %(reference)s) :tada:"
            % self.data,
            username="******",
            icon_emoji=":ticket:",
        )

        # Invite to public slack
        public_slack = get_slack_connection('djangoconeu-attendees')
        channels = _get_channels_for_ticket(self.data['release_title'].lower())
        channels = _convert_channels(public_slack, channels)
        if channels:
            try:
                public_slack.users.invite(
                    email=self.data['email'],
                    first_name=self.data['first_name'],
                    last_name=self.data['last_name'],
                    channels=channels,
                )
            except SlackError as e:
                if e.args[0] not in {'already_invited', 'already_in_team'}:
                    raise

        return self.ok(request)
    def ticket_completed(self, request):
        email = self.data['email']
        logger.info("New registration with email %s", email)

        # Post message to internal slack notification channel
        internal_slack = get_slack_connection('djangoconeu')
        internal_slack.chat.post_message(
            channel='#notifications',
            text="%(name)s registered a %(release_title)s (reference: %(reference)s) :tada:" % self.data,
            username="******",
            icon_emoji=":ticket:",
        )

        # Invite to public slack
        public_slack = get_slack_connection('djangoconeu-attendees')
        channels = _get_channels_for_ticket(self.data['release_title'].lower())
        channels = _convert_channels(public_slack, channels)
        if channels:
            try:
                public_slack.users.invite(
                    email=self.data['email'],
                    first_name=self.data['first_name'],
                    last_name=self.data['last_name'],
                    channels=channels,
                )
            except SlackError as e:
                if e.args[0] not in {'already_invited', 'already_in_team'}:
                    raise

        return self.ok(request)