示例#1
0
    def get_user_games(cls):
        """Returns all of the current User's active games"""
        gplus_user = get_endpoints_current_user()
        user = User.query(User.email == gplus_user.email()).get()

        active_games = Game.query() \
            .filter(Game.user == user.key) \
            .filter(Game.game_over == False)
        return GameForms(games=[game.to_form() for game in active_games])
示例#2
0
    def get(self):
        """Send a reminder email to each User with incomplete active games.
        Called every 24 hours using a cron job"""
        app_id = app_identity.get_application_id()
        games = Game.query(Game.game_over == False)
        users = []

        for game in games:
            user = game.user.get()
            if user not in users:  # Limit emails to 1 per user per day
                users.append(user)

        for user in users:
            subject = 'This is a reminder!'
            body = 'Hello {}, come back and finish your game of Rock, Paper, Scissors!'.format(user.displayName)
            mail.send_mail('noreply@{}.appspotmail.com'.format(app_id),
                           user.email,
                           subject,
                           body)