本文整理汇总了Python中skylines.model.Follower.follow方法的典型用法代码示例。如果您正苦于以下问题:Python Follower.follow方法的具体用法?Python Follower.follow怎么用?Python Follower.follow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skylines.model.Follower
的用法示例。
在下文中一共展示了Follower.follow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: follow
# 需要导入模块: from skylines.model import Follower [as 别名]
# 或者: from skylines.model.Follower import follow [as 别名]
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()
示例2: follow
# 需要导入模块: from skylines.model import Follower [as 别名]
# 或者: from skylines.model.Follower import follow [as 别名]
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'))
示例3: test_following
# 需要导入模块: from skylines.model import Follower [as 别名]
# 或者: from skylines.model.Follower import follow [as 别名]
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
示例4: follow
# 需要导入模块: from skylines.model import Follower [as 别名]
# 或者: from skylines.model.Follower import follow [as 别名]
def follow(self):
Follower.follow(request.identity['user'], self.user)
create_follower_notification(self.user, request.identity['user'])
redirect('.')
示例5: follow
# 需要导入模块: from skylines.model import Follower [as 别名]
# 或者: from skylines.model.Follower import follow [as 别名]
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'))
示例6: follow
# 需要导入模块: from skylines.model import Follower [as 别名]
# 或者: from skylines.model.Follower import follow [as 别名]
def follow(self):
Follower.follow(request.identity['user'], self.user)
redirect('.')