def get(self, team_id): repository = TeamRepository() team = repository.get(team_id) if team is None: raise error.NotFoundException('No such team: {}'.format(team_id)) return team.slack.get_channels()
def post(self): team_id = self.request.get('id') if not team_id: raise error.TaskUnrecoverableException( error.BadRequestException('`id` parameter is not specified')) repository = TeamRepository() team = repository.get(team_id) if team is None: raise error.TaskUnrecoverableException( error.NotFoundException('No such team: {}'.format(team_id))) team.timer.stop()
def get(self, invitation_code): repository = TeamRepository() team = repository.get_by_invitation_code(invitation_code) if team is None: raise error.NotFoundException('Invitation code is invalid.') if self.user is None: self.session['origin_url'] = self.request.url self.redirect('/signin/google') return firebase.add_team_user(team.id, self.user.id) self.redirect('/#teams/{}'.format(team.id))
def get(self, team_id): repository = TeamRepository() team = repository.get(team_id) if team is None: raise error.NotFoundException('No such team: {}'.format(team_id)) if not team.is_member(self.user.id): raise error.UnauthorizedException('No such member: {}'.format( self.user.id)) if team.slack.is_notify(): team.slack.notify_stop() return team.timer.stop()
def post(self): team_id = self.request.get('id') if not team_id: raise error.TaskUnrecoverableException( error.BadRequestException('`id` parameter is not specified')) repository = TeamRepository() team = repository.get(team_id) if team is None: raise error.TaskUnrecoverableException( error.NotFoundException('No such team: {}'.format(team_id))) repository.add_pomodoro(team) team.timer.stop_after_break() if team.slack.is_notify(): team.slack.notify_end()
def get(self): code = self.request.params.get('code', 'none') state = self.request.params.get('state') team_id = check_state(self.session_id, state) team = TeamRepository.get(team_id) if not team: raise error.NotFoundException('No such team: {}'.format(team_id)) provider = OAuth2Session(secret.SLACK_CLIENT_ID, scope=[','.join(AUTH_SCOPE)], redirect_uri=secret.SLACK_TEAM_REDIRECT_URI) token = provider.fetch_token(TOKEN_URL, client_secret=secret.SLACK_CLIENT_SECRET, code=code) token = token['access_token'] api = infra.slack.API(token) slack_team = api.get_team_info()['team'] team.slack.update(token, slack_team['name'], slack_team['domain']) self.redirect('/#teams/{}'.format(team.id))