Exemple #1
0
    def _create_credentials(self, raw_user, league_id=None, inviter_id=None):
        """ Create a new User and Player from raw user credentials. """

        # TODO: there are a lot of open questions here:
        # 1/ maybe fix this parameter list...it's ridiculous!
        # 2/ what about when we want to create a Person who isn't a Player?
        # 3/ when other credentialing options exist, it might not be good to
        #    assume exclusively.
        # 4/ is it more sensible to keep these methods separate if it turns out
        #    we can't easily generalize across other Person subclasses?
        (user, player) = User.create_user_and_player(
            PROPERTY_VALUE.EMPTY,
            PROPERTY_VALUE.EMPTY,
            None,
            PROPERTY_VALUE.EMPTY,
            PROPERTY_VALUE.EMPTY,
            {THIRD_PARTY.FACEBOOK: raw_user},
            inviter_id,
            self._ip,
            self._locale,
        )

        # TODO: uncomment TAGGED SqEdge type and pass optional third argument.
        if league_id is not None:
            Person.join_league(player.id, league_id)

        return (user, player)
Exemple #2
0
    def _load_credentials(self, raw_user):
        """ Return an existing user for a set of credentials. """
        fb_id = raw_user.get(NODE_PROPERTY.ID)

        if fb_id is None:
            raise tornado.web.HTTPError(500, "No Facebook User ID.")

        return User.load_by_external_id(fb_id, THIRD_PARTY.FACEBOOK)
Exemple #3
0
def generate_players(player_templates_list):
    user_player_tuples = []
    for p in player_templates_list:

        email = PROPERTY_VALUE.EMPTY
        password_hash = PROPERTY_VALUE.EMPTY
        referrer_url = PROPERTY_VALUE.EMPTY
        first_name = p['first_name']
        last_name = p['last_name']

        user_player_tuples.append(
                User.create_user_and_player(
                        email,
                        password_hash,
                        referrer_url,
                        first_name,
                        last_name))
    users = [user for user, player in user_player_tuples]
    players = [player for user, player in user_player_tuples]

    print("{0} Users created successfully.".format(len(users)))
    print("{0} Players created successfully.".format(len(players)))

    return (users, players)