示例#1
0
文件: roles.py 项目: sandeez/lino
    def get_user_profiles(cls):
        """Yield a series of all user profiles on this site which satisfy this
        role.

        """
        from lino.modlib.users.choicelists import UserProfiles
        for p in UserProfiles.items():
            if p.has_required_roles([cls]):
                yield p
示例#2
0
文件: utils.py 项目: zhuangyan/lino
 def instance(cls):
     if cls._instance is None:
         # Call startup() to fill UserProfiles also in a
         # multi-threaded environment:
         settings.SITE.startup()
         cls._instance = AnonymousUser()
         from lino.modlib.users.choicelists import UserProfiles
         cls._instance.profile = UserProfiles.get_by_value(
             settings.SITE.anonymous_user_profile, None)
         if cls._instance.profile is None:
             raise Exception(
                 "Invalid value %r for `SITE.anonymous_user_profile`. "
                 "Must be one of %s" % (
                     settings.SITE.anonymous_user_profile,
                     [i.value for i in UserProfiles.items()]))
     return cls._instance