当前位置: 首页>>代码示例>>Python>>正文


Python User.get_all方法代码示例

本文整理汇总了Python中models.User.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_all方法的具体用法?Python User.get_all怎么用?Python User.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.User的用法示例。


在下文中一共展示了User.get_all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
def create():
    context = get_context()
    context.update(dict(success=False))
    user = User.get_or_create(email=context['email'])
    all_users = User.get_all(exclude_user_id=user.id)
    context.update({'all_users': list(all_users)})
    if request.method == 'POST':
        group = Group.get_or_create(name=request.form['group_name'], status='Pending')
        UserGroup.get_or_create(
            user_id=user.id,
            group_id=group.id,
            loan_amount=request.form['loan_amount'],
            repaid_amount='0',
        )
        all_users = User.get_all(exclude_user_id=user.id)
        for _user in all_users:
            UserGroup.get_or_create(
                user_id=_user.id,
                group_id=group.id,
                loan_amount='0',
                repaid_amount='0',
            )

        context.update(dict(success=True))
    return render_template('create.html', **context)
开发者ID:maxgutman,项目名称:mkopo,代码行数:27,代码来源:app.py

示例2: accept_or_decline_friend

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
def accept_or_decline_friend(action, user, content):
    """Request/accept/decline friend requests."""
    emails = content['emails']
    others = User.get_all(emails)

    if not others:
        return jsonify(), 418

    if action == 'add':
        [user.add(other) for other in others]

        if other.device:
            notify(
                [other.device],
                'Politically Incorrect',
                '{} added you as a friend!'.format(user.name)
            )

    elif action == 'delete':
        [user.delete(other) for other in others]

    else:
        return jsonify(), 404

    try:
        db.session.commit()
    except:
        db.session.rollback()
        raise

    return jsonify()
开发者ID:25cf,项目名称:politically-incorrect,代码行数:33,代码来源:user.py

示例3: create

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
def create():
    context = get_context()
    context.update(dict(success=False))
    user = User.get_or_create(email=context['email'])
    all_users = User.get_all(exclude_user_id=user.id)
    context.update({'all_users': list(all_users)})
    if request.method == 'POST':
        context.update(dict(success=True))
    return render_template('create.html', **context)
开发者ID:renubora,项目名称:mkopo,代码行数:11,代码来源:app.py

示例4: create_game

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
def create_game(user, content):
    """Creates a pending game."""
    name        = content['name']
    max_points  = max(content['max_points'], 5)
    max_players = content['max_players']
    random      = content['random']
    emails      = content['emails']

    if len(emails) < 3:
        return jsonify(message='You need to invite more people!'), 418

    game = Game.create(
        user, name, max_points, min(max_players, len(emails) + 1), random
    )
    users   = User.get_all(emails) + [user]
    players = Player.create_all(users, game)

    player = next(
        (player for player in players if player.user == user),
        None
    )
    player.set_status_joined()

    notify(
        [u.device for u in users if u != user],
        'Politically Incorrect',
        'You\'ve been invited to a game: "{}"!'.format(name)
    )

    try:
        db.session.commit()
    except:
        db.session.rollback()
        raise

    return jsonify(**{
        'id'         : game.id,
        'name'       : game.name,
        'max_points' : game.max_points,
        'max_players': game.max_players,
        'status'     : game.status,
        'players'    : [
            {
                'name'  : p.user.name,
                'email' : p.user.email,
                'status': p.status
            }
            for p in game.players
        ]
    })
开发者ID:25cf,项目名称:politically-incorrect,代码行数:52,代码来源:game.py

示例5: get_player_standings

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
    def get_player_standings(self, request, **kwargs):
        """ Shows the player leaderboards, ranked by game win percentage """
        standings = []
        for user in User.get_all():
            games_played = 0
            games_won = 0            
            result = Game.query(Game.active == False, Game.player_keys.IN([user.key])).fetch()
            if result:
                games_played = float(len(result))
            
            result = Game.query(Game.active == False, Game.winner_key == user.key).fetch()
            if result:
                games_won = float(len(result))

            win_perc = games_won / games_played
            standings.append((user, win_perc))
        sorted_standings = sorted(standings, key=self.get_key)
        return create_leaderboard_collection(sorted_standings)
开发者ID:csarradet,项目名称:fsndp4,代码行数:20,代码来源:api.py

示例6: invite

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
def invite(id, user, content):
    """Invites a list of users."""
    game = Game.get(id)

    if not (user == game.host and game.status == Game.PENDING):
        return jsonify(message='I can\'t let you do that, Dave.'), 418

    emails  = content['emails']
    users   = User.get_all(emails)
    players = Player.create_all(users, game)
    game.invite_all(players)

    try:
        db.session.commit()
    except:
        db.session.rollback()
        raise

    return jsonify()
开发者ID:25cf,项目名称:politically-incorrect,代码行数:21,代码来源:game.py

示例7: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
 def get(self):
     #cache_key = 'UserListHandler'
     #cached_response = memcache.get(cache_key)
     #if cached_response:
     #    self.response.out.write(cached_response)
     #else:
     #    users = User.all().order('nickname').fetch(MAX_FETCH_LIMIT)
     #    user_list = []
     #    for user in users:
     #        user_list.append(user.to_json_dict('nickname',
     #            'is_starred', 'is_active', 'is_deleted', 'when_created'))
     #    response = json.dumps(user_list)
     #    memcache.set(cache_key, response, 60)
     #    self.response.out.write(response)
     users = User.get_all()
     user_list = []
     for user in users:
         user_list.append(user.to_json_dict('nickname',
             'auth_provider', 'signin_email', 'is_starred',
             'is_active', 'is_deleted', 'when_created'))
     response = json.dumps(user_list)
     self.response.out.write(response)
开发者ID:spaceone,项目名称:mils-secure,代码行数:24,代码来源:api.py

示例8: list_users

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
 def list_users(self, request):
     """ List all users that have ever interacted with the system """
     response = UserCollection()
     response.user_messages = [user_to_message(x) for x in User.get_all()]
     return response
开发者ID:csarradet,项目名称:fsndp4,代码行数:7,代码来源:api.py

示例9: users

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
def users():
    # Retrieve all the users so we can display them in a table
    all_users = User.get_all()
    return render_template('users.html', all_users=all_users)
开发者ID:pacerrabbit,项目名称:mock-signup-page,代码行数:6,代码来源:app.py

示例10: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
	def get(self):

		doctors=User.get_all() or []
		self.render('browse.html', doctors=doctors, user=self.user)
开发者ID:sanketsaurav,项目名称:mseva,代码行数:6,代码来源:views.py

示例11: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
 def get(self, *args, **kwargs):
     ''' Renders the view users page '''
     self.render("admin/view_users.html",
                 total_users=User.get_all(),
                 )
开发者ID:brutalhonesty,项目名称:The-Planetary-Assault-System,代码行数:7,代码来源:AdminHandlers.py

示例12: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_all [as 别名]
 def get(self, *args, **kwargs):
     '''Renders Highscore page'''
     user = self.get_current_user()
     self.render('user/highscore.html', user=user, all_users=User.get_all())
开发者ID:hathcox,项目名称:Arthur,代码行数:6,代码来源:UserHandlers.py


注:本文中的models.User.get_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。