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


Python Location.select方法代码示例

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


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

示例1: show_userlist

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import select [as 别名]
def show_userlist():
    if auth.get_logged_in_user().admin:
        user_list = Location.select(Location.username, Location.device, Location.topic).distinct().order_by(Location.username.asc())
        return render_template('userlist.html', users = user_list, cur_user = auth.get_logged_in_user())
    else:
        # Only admins can get the full userlist
        # so go away. shoo, shoo.
        return redirect('/devicelist/%s' % auth.get_logged_in_user().username, 302)
开发者ID:RustyDust,项目名称:backend,代码行数:10,代码来源:views.py

示例2: gpx_generate

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import select [as 别名]
def gpx_generate(username, device, from_date, to_date):
    
    query = Location.select().where(
                (Location.username == username) &
                (Location.device == device) &
                (Location.tst.between(from_date, to_date))
            )
    query = query.order_by(Location.tst.asc())

    result = render_template('gpx.html', data=query)

    return Response(result, mimetype='text/xml')
开发者ID:RustyDust,项目名称:backend,代码行数:14,代码来源:views.py

示例3: hello_world

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import select [as 别名]
def hello_world(cur_user):
    username = 'stefan'
    device = 'Note3'
    from_date = '2013-10-08'
    to_date = '2015-12-31'

    query = Location.select().where(
                (Location.username == username) &
                (Location.device == device) &
                (Location.tst.between(from_date, to_date))
            )
    query = query.order_by(Location.tst.asc())

    print query

    return render_template('base.html', location=query)
开发者ID:RustyDust,项目名称:backend,代码行数:18,代码来源:views.py

示例4: io_find_nearest_query

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import select [as 别名]
def io_find_nearest_query(query):
    if 'location' in query:
        # choose some reasonable defaults for now
        query.setdefault('target_class', 'bike-parking')
        query.setdefault('limit', 5)
        query.setdefault('max_distance', 1000)

        # IGNORE target_class for now
        LOG.debug(u"User is at " + str(query['location']))
        LOG.debug(u"Let's find the {} nearest {}".format(query['limit'], query['target_class']))
        longitude = query.get('location', {}).get('coords', {}).get('longitude', None)
        latitude = query.get('location', {}).get('coords', {}).get('latitude', None)
        results = []
        if longitude and latitude:
            for location in Location.select().filter(Location.location_name != '_undetermined'):
                km_distance = haversine(longitude, latitude,
                    location.coord_longitude, location.coord_latitude)
                if km_distance < query['max_distance']:
                    # NOTE: Reverse priority queue would be a more optimal way of doing this insertion.
                    # NOTE: See slicing below.
                    results.append({
                        'km_distance': km_distance,
                        'location': location.serialize()
                        })
                else:
                    LOG.info('Filtering out {} because it is {}km away.'.format(location.yr_inst, km_distance))
            limit = query.get('limit')
            LOG.info("Found {} parking spots".format(len(results)))
            emit('bike-parking-results', {
                'status': StatusChoices.Ok,
                'locations': [result['location'] for result in sorted(results, key=lambda x:x['km_distance'])[:limit]]
                })
        # else:
            # LOG.error("No lat/lon in location query")
            # emit('bike-parking-results', {
                # 'status': 'error',
                # 'error_message': 'No latitude/longitude in location query'
                # })
    else:
        LOG.error("No location specified in query.")
        emit('bike-parking-results', {
            'status': StatusChoices.Error,
            'error_message': 'No location specified in query.'
            })
开发者ID:wbbradley,项目名称:bike,代码行数:46,代码来源:server.py

示例5: show_user_devices

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import select [as 别名]
def show_user_devices(username):
    device_list = Location.select(Location.device, Location.topic).distinct().where(Location.username == username).order_by(Location.device.asc())
    return render_template('devicelist.html', devices = device_list, cur_user = auth.get_logged_in_user())
开发者ID:RustyDust,项目名称:backend,代码行数:5,代码来源:views.py


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