本文整理汇总了Python中model.User.get_private_properties方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_private_properties方法的具体用法?Python User.get_private_properties怎么用?Python User.get_private_properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.get_private_properties方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_private_properties [as 别名]
def get(self, username):
"""Loads user's properties. If logged user is admin it loads also non public properties"""
if auth.is_admin():
properties = User.get_private_properties()
else:
properties = User.get_public_properties()
traveler_key = getattr(g.user_db,'fellow_traveler',None)
if traveler_key:
traveler = traveler_key.get()
future=False
else:
traveler = model.FellowTraveler.create_or_update(
name=g.user_db.name,
email=g.user_db.email,
avatar_url=g.user_db.avatar_url,
parent=g.user_db.key,
added_by=g.user_db.key)
traveler_key =traveler.put()
traveler.key = traveler_key
g.user_db.fellow_traveler = traveler_key
future = g.user_db.put_async()
db_dict = g.user_db.to_dict(include=properties)
db_dict["fellow_traveler"] = traveler.to_dict(include=model.FellowTraveler.get_public_properties())
if future:
future.get_result()
return db_dict
示例2: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_private_properties [as 别名]
def post(self):
"""Creates new user account if provided valid arguments"""
parser = reqparse.RequestParser()
parser.add_argument('email', type=UserValidator.create('unique_email'), required=True)
parser.add_argument('username', type=UserValidator.create('unique_username'))
parser.add_argument('password', type=UserValidator.create('password'))
parser.add_argument('remember', type=inputs.boolean, default=False)
args = parser.parse_args()
user_db = auth.create_user_db(
auth_id=None,
name='',
username=args.username,
email=args.email,
verified=True if not config.CONFIG_DB.verify_email else False,
password=args.password
)
user_db.put()
if config.CONFIG_DB.verify_email:
task.verify_user_email_notification(user_db)
return make_empty_ok_response()
# if users don't need to verify email, we automaticaly signin newly registered user
auth.signin_user_db(user_db, remember=args.remember)
return user_db.to_dict(include=User.get_private_properties())
示例3: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_private_properties [as 别名]
def get(self, username):
"""Loads user's properties. If logged user is admin it loads also non public properties"""
if auth.is_admin():
properties = User.get_private_properties()
else:
properties = User.get_public_properties()
return g.user_db.to_dict(include=properties)
示例4: inject_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_private_properties [as 别名]
def inject_user():
"""Injects 'user' variable into jinja template, so it can be passed into angular. See base.html"""
user = False
if auth.is_logged_in():
user = auth.current_user_db().to_dict(include=User.get_private_properties())
return {
'user': user
}
示例5: put
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_private_properties [as 别名]
def put(self, key):
"""Updates user's properties"""
update_properties = ['name', 'bio', 'email', 'location', 'avatar_url', 'facebook', 'github',
'gplus', 'linkedin', 'twitter', 'instagram']
if auth.is_admin():
update_properties += ['verified', 'active', 'admin']
new_data = _.pick(request.json, update_properties)
g.model_db.populate(**new_data)
g.model_db.put()
#return make_empty_ok_response()
if auth.is_admin():
properties = User.get_private_properties()
else:
properties = User.get_public_properties()
return g.model_db.to_dict(include=properties)
示例6: inject_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_private_properties [as 别名]
def inject_user():
"""Injects 'user' variable into jinja template, so it can be passed into angular. See base.html"""
user = False
user_future = False
if auth.is_logged_in():
user_db = auth.current_user_db()
user = user_db.to_dict(include=User.get_private_properties())
traveler_key = getattr(user_db,'fellow_traveler',None)
if traveler_key:
traveler = traveler_key.get()
else:
traveler = model.FellowTraveler(name=user_db.name,
email=user_db.email,
avatar_url=user_db.avatar_url,
added_by=user_db.key)
traveler_key =traveler.put()
user_db.fellow_traveler = traveler_key
user_future = user_db.put_async()
user["fellow_traveler"] = traveler.to_dict(include=model.FellowTraveler.get_public_properties())
if user_future:
user_future.get_result()
return {
'user': user
}