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


Python PosGraduationFactory.post_graduations_dao方法代码示例

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


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

示例1: get

# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import post_graduations_dao [as 别名]
 def get(nick, authenticated=False):
     """Return an User from database. If failed, None."""
     try:
         condition = {'users.nick': nick}
         pfactory = PosGraduationFactory()
         dao = pfactory.post_graduations_dao()
         program = list(dao.find(condition))
         if program:
             initials = program[0]['initials']
         else:
             return None
         for user in program[0]['users']:
             if nick.lower() == user['nick'].lower():
                 found_user = User()
                 found_user._nick = user['nick']
                 found_user._pg_initials = initials.lower()
                 found_user._full_name = user['fullName']
                 found_user._role = user['role']
                 found_user._email = user['email']
                 found_user._token = user['token']
                 found_user.__is_authenticated = authenticated
                 found_user.__is_active = True
                 found_user.__is_anonymous = False
                 return found_user
         return None
     except (TypeError, AttributeError):
         return None
开发者ID:Mazuh,项目名称:OAuth2Client-PHP-APIsistemas-PPGP,代码行数:29,代码来源:users.py

示例2: get_std_for_template

# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import post_graduations_dao [as 别名]
def get_std_for_template(post_graduation, give_me_empty=False):
    """
    Return default template stuff for jinja to render.

    Freely put None if theres no post_graduation dict.
    But if there's one, must be the found by DAOs
    and requested by user.

    Must be called like this in every template:
        return render_template('MYTEMPLATE.html', std=get_std_for_template(None), ...)
    That said, there will always be a std dict in jinja environments.

    Jinja will have following template vars, if you called it right:
        std.post_graduation (dict for current given post graduation)
        std.post_graduations_registered (dict for the post graduations available at minerva)
        std.post_graduations_unregistered (dict for post graduations unavailable at minerva)
    They can be None if nothing has found from database or provided by function args.

    Jinja will have the following template vars, if you called it with give_me_empty=True:
        std.post_graduation == None
        std.post_graduations_registered == []
        std.post_graduations_unregistered == []
    """
    if give_me_empty:
        return {
            'post_graduation': None,
            'post_graduations_registered': [],
            'post_graduations_unregistered': [],
        }
    else:
        pfactory = PosGraduationFactory()
        post_graduations_registered = pfactory.post_graduations_dao().find({'isSignedIn': True})
        post_graduations_unregistered = pfactory.post_graduations_dao().find({'isSignedIn': False})
        return {
            'post_graduation': post_graduation,
            'post_graduations_registered': post_graduations_registered,
            'post_graduations_unregistered': post_graduations_unregistered,
        }
开发者ID:Mazuh,项目名称:OAuth2Client-PHP-APIsistemas-PPGP,代码行数:40,代码来源:public.py


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