コード例 #1
0
]

for team in teams:
    t = Team(name=team, key_name=team, enabled=True)
    t.put()
    print 'Team with name \"%s\" created.' %t.name
    

random_banter = [
    '%s fans should better find a new team.',
    'I can\'t understand how %s call themselves a team.',
    'A footbal team? I thought you said %s.',
]

print ''

for team in teams:
    for banter in random_banter:
        b = Banner(
            copy = banter %team,
            team = Team.get_by_key_name(team),
            author_id = '*****@*****.**',
            impressions = 5
        )
        b.put()
        print 'New banter banner'
        print 'Banter: %s' %b.copy
        print 'Sent to: %s' %b.team.name
        print 'Impressions left: %i' %b.impressions
        print ''
    print ''
コード例 #2
0
ファイル: test.py プロジェクト: grancalavera/Banter-Banners
from main import Banner, Team
import main

team = Team.get_by_key_name('Birmingham City')
print 'Banners for the %s team' % team.name

banner = main.get_banner_for_team(team)

if banner:
    print banner.copy
else:
    print 'All of the banners for the %s team have run out of impressions' % team.name
コード例 #3
0
ファイル: populate.py プロジェクト: MagicPwn/Banter-Banners
    def get(self):
        
        resultlog = []
        
        for team in Team.all():
            team.delete()

        for banner in Banner.all():
            banner.delete()

        teams = [
            'Arsenal',
            'Aston Villa',
            'Birmingham City',
            'Blackburn Rovers',
            'Blackpool',
            'Bolton Wanderers',
            'Chelsea',
            'Everton',
            'Fulham',
            'Liverpool',
            'Manchester City',
            'Manchester United',
            'Newcastle United',
            'Stoke City',
            'Sunderland',
            'Tottenham Hotspur',
            'West Bromwich Albion',
            'West Ham United',
            'Wigan Athletic',
            'Wolverhampton Wanderers',
        ]

        for team in teams:
            t = Team(name=team, key_name=team, enabled=True)
            t.put()
            resultlog.append('Team with name \"%s\" created.' %t.name)


        random_banter = [
            '%s fans should better find a new team.',
            'I can\'t understand how %s call themselves a team.',
            'A footbal team? I thought you said %s.',
        ]

        resultlog.append('')
        
        impressions = int(self.request.get('impressions', default_value=2000))
        
        for team in teams:
            for banter in random_banter:
                b = Banner(
                    copy = banter %team,
                    team = Team.get_by_key_name(team),
                    author_id = 'leoncoto',
                    impressions = impressions
                )
                b.put()
                resultlog.append('New banter banner')
                resultlog.append('Banter: %s' %b.copy)
                resultlog.append('Sent to: %s' %b.team.name)
                resultlog.append('Impressions left: %i' %b.impressions)
                resultlog.append('')
            resultlog.append('')   

        template_values = {'resultlog' : resultlog }
        path = os.path.join(os.path.dirname(__file__), 'templates/pupulate.html')
        template_render = template.render(path, template_values)
        self.response.out.write(template_render)        
コード例 #4
0
    def get(self):

        resultlog = []

        for team in Team.all():
            team.delete()

        for banner in Banner.all():
            banner.delete()

        teams = [
            'Arsenal',
            'Aston Villa',
            'Birmingham City',
            'Blackburn Rovers',
            'Blackpool',
            'Bolton Wanderers',
            'Chelsea',
            'Everton',
            'Fulham',
            'Liverpool',
            'Manchester City',
            'Manchester United',
            'Newcastle United',
            'Stoke City',
            'Sunderland',
            'Tottenham Hotspur',
            'West Bromwich Albion',
            'West Ham United',
            'Wigan Athletic',
            'Wolverhampton Wanderers',
        ]

        for team in teams:
            t = Team(name=team, key_name=team, enabled=True)
            t.put()
            resultlog.append('Team with name \"%s\" created.' % t.name)

        random_banter = [
            '%s fans should better find a new team.',
            'I can\'t understand how %s call themselves a team.',
            'A footbal team? I thought you said %s.',
        ]

        resultlog.append('')

        impressions = int(self.request.get('impressions', default_value=2000))

        for team in teams:
            for banter in random_banter:
                b = Banner(copy=banter % team,
                           team=Team.get_by_key_name(team),
                           author_id='leoncoto',
                           impressions=impressions)
                b.put()
                resultlog.append('New banter banner')
                resultlog.append('Banter: %s' % b.copy)
                resultlog.append('Sent to: %s' % b.team.name)
                resultlog.append('Impressions left: %i' % b.impressions)
                resultlog.append('')
            resultlog.append('')

        template_values = {'resultlog': resultlog}
        path = os.path.join(os.path.dirname(__file__),
                            'templates/pupulate.html')
        template_render = template.render(path, template_values)
        self.response.out.write(template_render)