本文整理汇总了Python中models.favorite.Favorite.select方法的典型用法代码示例。如果您正苦于以下问题:Python Favorite.select方法的具体用法?Python Favorite.select怎么用?Python Favorite.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.favorite.Favorite
的用法示例。
在下文中一共展示了Favorite.select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_profile
# 需要导入模块: from models.favorite import Favorite [as 别名]
# 或者: from models.favorite.Favorite import select [as 别名]
def user_profile(user, params, lang):
origin_user = user
uuid = params.get("uuid", "")
if uuid:
user = User.select().where(User.uuid == uuid).first()
if not user:
return {"error_code": 20002, "msg": "user not exist"}
profile = user.profile.first()
languages = []
ul = UserLanguage.select().where(UserLanguage.user == user)
for u in ul:
languages.append(dict(
language_id=u.id,
name=u.name,
level=u.level,
))
out = dict()
# user self can get private information
if not uuid:
out["reg_step"] = user.reg_step
out["id_number"] = "%s********%s" % (profile.id_number[:6], profile.id_number[14:]) if profile.id_number else ""
out["alipay"] = profile.alipay
out["email"] = user.email
out["phone"] = user.phone
out["name"] = profile.name
out["username"] = user.username
out["avatar"] = widget.avatar(profile.avatar)
out["completeness"] = profile.completeness
out["visibility"] = profile.visibility
out["level"] = profile.level
out["title"] = profile.title
out["overview"] = profile.overview
out["hourly"] = profile.hourly
out["english"] = profile.english
out["skills"] = utils.loads(profile.skills) if profile.skills else []
out["available"] = profile.available
out["workload"] = profile.workload
location = {}
if profile.location_id:
city = widget.get_location(profile.location_id)
province = widget.get_location(city.parent_id)
location["location_id"] = profile.location_id
location["name"] = utils.lang_map_name(city.name, city.ename, lang)
location["parent_id"] = province.id
location["parent_name"] = utils.lang_map_name(province.name, province.ename, lang)
out["location"] = location
out["address"] = profile.address
out["postcode"] = profile.postcode
out['id'] = user.uuid
out["languages"] = languages
out["imid"] = user.id
if uuid:
favorites = Favorite.select().where(Favorite.user==origin_user, Favorite.target_id==profile.user_id, Favorite.ftype == 'REQ').first()
if favorites:
out["favorite"] = True
else:
out["favorite"] = False
# 开发者的评价数量和平均得分
score = UserStatistics.select(UserStatistics.eveluate_num, UserStatistics.aver_score).where(UserStatistics.user == user).first()
out["eveluate_num"] = score.eveluate_num if score else 0
out["aver_score"] = score.aver_score if score else 0
return {"error_code": 0, "msg": "ok", "profile": out}