def get(self): votes = Votes.for_user(users.get_current_user()) city = self.get_user_city(votes) if city is None: self.render('listlocal_fail', { }) else: all_teams = Team.for_city(city) votes = Votes.for_user(users.get_current_user()) for team in all_teams: team.voted = (team.key() in votes.local_teams or team.key() in votes.teams) self.render('listlocal', { 'city': city, 'teams': all_teams })
def get(self): existing = Team.for_user(users.get_current_user()) votes = Votes.for_user(users.get_current_user()) city = self.get_user_city(votes) if city is None: self.render('listlocal_fail', { }) else: all_teams = Team.for_city(city) all_teams.sort(key=attrgetter('local_votes')) self.render('winnerslocal', { 'teams': all_teams, 'city': city, 'team': existing })
def get(self): current_user = users.get_current_user() votes = Votes.for_user(current_user) team_comments = {} user_comments = {} if shouldShowComments(): comments = Comment.all() for comment in comments: team_key = str(comment.team.key()) comment.author_name = generateCommentAuthorName(comment) if not team_key in team_comments: team_comments[team_key] = [] if comment.user == current_user: user_comments[team_key] = comment team_comments[team_key].append(comment) all_teams = filter_hidden(Team.all().fetch(1000)) for team in all_teams: team.voted = (team.key() in votes.local_teams or team.key() in votes.teams) team_key = str(team.key()) if shouldShowComments(): if team_key in team_comments: team.comments = team_comments[team_key] if team_key in user_comments: team.user_comment = user_comments[team_key].text logout_url = users.create_logout_url("/") winning_teams = filter(lambda x: config['highlight_winners'] and x.annotation is not None and x.annotation != '', all_teams) all_teams = filter(lambda x: x not in winning_teams, all_teams) # Disable randomness for commenting always if config["list_teams_randomly"] and not shouldEnableCommenting(): random.shuffle(all_teams) random.shuffle(winning_teams) self.render('list', { 'teams': all_teams, 'winning_teams': winning_teams, 'votes': votes, 'team_comments': team_comments, 'user_comments': user_comments, 'highlight_winners': config['highlight_winners'], 'enable_voting': config['enable_voting'], 'enable_commenting': shouldEnableCommenting(), 'show_winner_entry': config['show_winner_entry'], 'logout_url': logout_url })
def get(self): code = self.request.get('code') client_id = 'EPMLCP1Y1MS1U1F3QRQAGZQSLNSGGLD5T5K3OTZUB1CMSKEB' client_secret = 'EZYSGRHUEGLRULLLGEYZKSVN1PV0RKWQJL3JL2D5QWQV0XWJ' redirect_uri = 'http://fshackathon.appspot.com/auth' if (self.request.url.find('localhost') > -1): client_id = 'QADWWPJPWQEJCBQT3BZ0KHZVDZED2VDHZWI23ZW45PA00OXF' client_secret = 'EIP4CULDABQQRZCL0AKNJYISGRMD43O4XE4QC2LO1OVCFGL5' redirect_uri = 'http://localhost:8000/auth' result = fetchJson('https://foursquare.com/oauth2/access_token?client_id=%s&client_secret=%s&grant_type=authorization_code&redirect_uri=%s&code=%s' % (client_id, client_secret, urllib.quote_plus(redirect_uri), code)) token = result['access_token'] votes = Votes.for_user(users.get_current_user()) votes.token = token votes.put() self.redirect('listlocal', False)
def get(self): team_key = self.request.get('team_key') team = Team.get(team_key) votes = Votes.for_user(users.get_current_user()) team.voted = (team.key() in votes.local_teams or team.key() in votes.teams) enable_commenting = False user_is_owner = users.get_current_user() == team.user if config["enable_owner_commenting"] and user_is_owner: enable_commenting = True if config['show_comments']: team.comments = list(Comment.get_team_comments(team)) for comment in team.comments: comment.author_name = generateCommentAuthorName(comment) self.render('team', { 'team': team, 'show_comments': config['show_comments'], 'enable_commenting': enable_commenting })
def get(self): current_user = users.get_current_user() votes = Votes.for_user(current_user) team_comments = {} user_comments = {} if shouldShowComments(): comments = Comment.all() for comment in comments: team_key = str(comment.team.key()) comment.author_name = comment.user.nickname().split('@', 1)[0] if not team_key in team_comments: team_comments[team_key] = [] if comment.user == current_user: user_comments[team_key] = comment team_comments[team_key].append(comment) all_teams = Team.all().fetch(1000) for team in all_teams: team.voted = (team.key() in votes.local_teams or team.key() in votes.teams) team_key = str(team.key()) if shouldShowComments(): if team_key in team_comments: team.comments = team_comments[team_key] if team_key in user_comments: team.user_comment = user_comments[team_key].text logout_url = users.create_logout_url("/") # Disable randomness for commenting always if config["list_teams_randomly"] and not shouldEnableCommenting(): random.shuffle(all_teams) self.render('list', { 'teams': all_teams, 'votes': votes, 'team_comments': team_comments, 'user_comments': user_comments, 'enable_voting': config['enable_voting'], 'enable_commenting': shouldEnableCommenting(), 'logout_url': logout_url })
def get(self): team_key = self.request.get('team_key') team = Team.get(team_key) votes = Votes.for_user(users.get_current_user()) team.voted = (team.key() in votes.local_teams or team.key() in votes.teams) self.render('team', { 'team': team })