• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python model.Follower类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中skylines.model.Follower的典型用法代码示例。如果您正苦于以下问题:Python Follower类的具体用法?Python Follower怎么用?Python Follower使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: follow

def follow(user_id):
    user = get_requested_record(User, user_id)
    current_user = User.get(request.user_id)
    Follower.follow(current_user, user)
    create_follower_notification(user, current_user)
    db.session.commit()
    return jsonify()
开发者ID:skylines-project,项目名称:skylines,代码行数:7,代码来源:users.py


示例2: follow

def follow():
    Follower.follow(g.current_user, g.user)
    create_follower_notification(g.user, g.current_user)
    db.session.flush()

    unlock_user_achievements(g.current_user, FOLLOW_ACHIEVEMENTS)
    unlock_user_achievements(g.user, FOLLOWER_ACHIEVEMENTS)
    db.session.commit()
    return redirect(request.referrer or url_for('.index'))
开发者ID:kedder,项目名称:skylines,代码行数:9,代码来源:user.py


示例3: index

def index():
    if 'application/json' not in request.headers.get('Accept', ''):
        return render_template('ember-page.jinja', active_page='tracking')

    fix_schema = TrackingFixSchema(only=('time', 'location', 'altitude', 'elevation', 'pilot'))
    airport_schema = AirportSchema(only=('id', 'name', 'countryCode'))

    @current_app.cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(airport=airport_schema.dump(airport).data,
                    distance=airport.distance(track.location))

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track['nearestAirport'] = nearest_airport['airport']
            track['nearestAirportDistance'] = nearest_airport['distance']

        tracks.append(track)

    if g.current_user:
        followers = [f.destination_id for f in Follower.query(source=g.current_user)]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
开发者ID:kerel-fs,项目名称:skylines,代码行数:33,代码来源:tracking.py


示例4: index

def index():
    fix_schema = TrackingFixSchema(only=('time', 'location', 'altitude', 'elevation', 'pilot'))
    airport_schema = AirportSchema(only=('id', 'name', 'countryCode'))

    @cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(airport=airport_schema.dump(airport).data,
                    distance=airport.distance(track.location))

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track['nearestAirport'] = nearest_airport['airport']
            track['nearestAirportDistance'] = nearest_airport['distance']

        tracks.append(track)

    if request.user_id:
        followers = [f.destination_id for f in Follower.query(source_id=request.user_id)]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
开发者ID:GliderGeek,项目名称:skylines,代码行数:30,代码来源:tracking.py


示例5: test_following

def test_following(db_session, client):
    john = users.john()
    jane = users.jane()
    add_fixtures(db_session, john, jane)
    Follower.follow(john, jane)

    res = client.get("/users/{id}".format(id=john.id))
    assert res.status_code == 200
    assert res.json["following"] == 1

    res = client.get("/users/{id}".format(id=jane.id))
    assert res.status_code == 200
    assert res.json["followers"] == 1
    assert "followed" not in res.json

    res = client.get("/users/{id}".format(id=jane.id), headers=auth_for(john))
    assert res.status_code == 200
    assert res.json["followers"] == 1
    assert res.json["followed"] == True
开发者ID:skylines-project,项目名称:skylines,代码行数:19,代码来源:read_test.py


示例6: following

def following():
    # Query list of pilots that are following the selected user
    query = Follower.query(source=g.user) \
        .join('destination') \
        .options(contains_eager('destination')) \
        .options(subqueryload('destination.club')) \
        .order_by(User.name)

    followers = [follower.destination for follower in query]

    add_current_user_follows(followers)

    return render_template('users/following.jinja', followers=followers)
开发者ID:Adrien81,项目名称:skylines,代码行数:13,代码来源:user.py


示例7: followers

def followers(user_id):
    user = get_requested_record(User, user_id)

    # Query list of pilots that are following the selected user
    query = Follower.query(destination=user) \
        .join('source') \
        .options(contains_eager('source')) \
        .options(subqueryload('source.club')) \
        .order_by(User.name)

    user_schema = UserSchema(only=('id', 'name', 'club'))
    followers = user_schema.dump([follower.source for follower in query], many=True).data

    add_current_user_follows(followers)

    return jsonify(followers=followers)
开发者ID:RBE-Avionik,项目名称:skylines,代码行数:16,代码来源:users.py


示例8: add_current_user_follows

def add_current_user_follows(followers):
    """
    If the user if signed in the followers will get an additional
    `current_user_follows` attribute, that shows if the signed in user is
    following the pilot
    """

    if not g.current_user:
        return

    # Query list of people that the current user is following
    query = Follower.query(source=g.current_user)
    current_user_follows = [follower.destination_id for follower in query]

    for follower in followers:
        follower.current_user_follows = (follower.id in current_user_follows)
开发者ID:Adrien81,项目名称:skylines,代码行数:16,代码来源:user.py


示例9: add_current_user_follows

def add_current_user_follows(followers):
    """
    If the user if signed in the followers will get an additional
    `current_user_follows` attribute, that shows if the signed in user is
    following the pilot
    """

    if not request.user_id:
        return

    # Query list of people that the current user is following
    query = Follower.query(source_id=request.user_id)
    current_user_follows = [follower.destination_id for follower in query]

    for follower in followers:
        follower["currentUserFollows"] = follower["id"] in current_user_follows
开发者ID:skylines-project,项目名称:skylines,代码行数:16,代码来源:users.py


示例10: following

def following(user_id):
    user = get_requested_record(User, user_id)

    # Query list of pilots that are following the selected user
    query = (
        Follower.query(source=user)
        .join("destination")
        .options(contains_eager("destination"))
        .options(subqueryload("destination.club"))
        .order_by(User.name)
    )

    user_schema = UserSchema(only=("id", "name", "club"))

    following = user_schema.dump(
        [follower.destination for follower in query], many=True
    ).data

    add_current_user_follows(following)

    return jsonify(following=following)
开发者ID:skylines-project,项目名称:skylines,代码行数:21,代码来源:users.py


示例11: index

def index():
    fix_schema = TrackingFixSchema(
        only=("time", "location", "altitude", "elevation", "pilot")
    )
    airport_schema = AirportSchema(only=("id", "name", "countryCode"))

    @cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        return dict(
            airport=airport_schema.dump(airport).data,
            distance=airport.distance(track.location),
        )

    tracks = []
    for t in TrackingFix.get_latest():
        nearest_airport = get_nearest_airport(t)

        track = fix_schema.dump(t).data
        if nearest_airport:
            track["nearestAirport"] = nearest_airport["airport"]
            track["nearestAirportDistance"] = nearest_airport["distance"]

        tracks.append(track)

    if request.user_id:
        followers = [
            f.destination_id for f in Follower.query(source_id=request.user_id)
        ]
    else:
        followers = []

    return jsonify(friends=followers, tracks=tracks)
开发者ID:skylines-project,项目名称:skylines,代码行数:36,代码来源:tracking.py


示例12: index

def index():
    tracks = TrackingFix.get_latest()

    @current_app.cache.memoize(timeout=(60 * 60))
    def get_nearest_airport(track):
        airport = Airport.by_location(track.location, None)
        if not airport:
            return None

        distance = airport.distance(track.location)

        return {
            'name': airport.name,
            'country_code': airport.country_code,
            'distance': distance,
        }

    tracks = [(track, get_nearest_airport(track)) for track in tracks]

    if g.current_user:
        followers = [f.destination_id for f in Follower.query(source=g.current_user)]

        def is_self_or_follower(track):
            pilot_id = track[0].pilot_id
            return pilot_id == g.current_user.id or pilot_id in followers

        friend_tracks = [t for t in tracks if is_self_or_follower(t)]
        other_tracks = [t for t in tracks if t not in friend_tracks]

    else:
        friend_tracks = []
        other_tracks = tracks

    return render_template('tracking/list.jinja',
                           friend_tracks=friend_tracks,
                           other_tracks=other_tracks)
开发者ID:imclab,项目名称:skylines,代码行数:36,代码来源:tracking.py


示例13: unfollow

 def unfollow(self):
     Follower.unfollow(request.identity['user'], self.user)
     redirect('.')
开发者ID:gabor-konrad,项目名称:Skylines,代码行数:3,代码来源:users.py


示例14: follow

 def follow(self):
     Follower.follow(request.identity['user'], self.user)
     create_follower_notification(self.user, request.identity['user'])
     redirect('.')
开发者ID:gabor-konrad,项目名称:Skylines,代码行数:4,代码来源:users.py


示例15: unfollow

def unfollow():
    Follower.unfollow(g.current_user, g.user)
    db.session.commit()
    return redirect(url_for('.index'))
开发者ID:imclab,项目名称:skylines,代码行数:4,代码来源:user.py


示例16: follow

def follow():
    Follower.follow(g.current_user, g.user)
    create_follower_notification(g.user, g.current_user)
    db.session.commit()
    return redirect(url_for('.index'))
开发者ID:imclab,项目名称:skylines,代码行数:5,代码来源:user.py


示例17: unfollow

def unfollow(user_id):
    user = get_requested_record(User, user_id)
    current_user = User.get(request.user_id)
    Follower.unfollow(current_user, user)
    db.session.commit()
    return jsonify()
开发者ID:skylines-project,项目名称:skylines,代码行数:6,代码来源:users.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.TrackingFix类代码示例发布时间:2022-05-27
下一篇:
Python model.Flight类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap