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


Python Favorite.select方法代码示例

本文整理汇总了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}
开发者ID:wdvill,项目名称:cloud_admin,代码行数:67,代码来源:user.py


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