本文整理汇总了Python中auth.models.User._get_user_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User._get_user_by_email方法的具体用法?Python User._get_user_by_email怎么用?Python User._get_user_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth.models.User
的用法示例。
在下文中一共展示了User._get_user_by_email方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_activity
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import _get_user_by_email [as 别名]
def get_user_activity(email, filters):
user = User._get_user_by_email(email)
activity_type = filters.get('activity_type', -1)
q = Activity.all().filter('user =', user).order('-created_on')
if activity_type and int(activity_type) != -1:
activity_type = ActivityType.get_by_id(int(activity_type))
q.filter('activity_type = ', activity_type)
if 'from_date' in filters and filters['from_date']:
q.filter('created_on >= ', filters['from_date'])
if 'to_date' in filters and filters['to_date']:
q.filter('created_on <= ', filters['to_date'])
results = list()
for i in q.run():
item = {
'id': i.key().id(),
'activity_type_name': i.activity_type.name,
'user_id': i.user.key().id(),
'created_on': i.created_on,
'hours': i.hours,
'minutes': i.minutes,
'seconds': i.seconds,
}
results.append(item)
return results
示例2: create_activity_type
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import _get_user_by_email [as 别名]
def create_activity_type(email, name):
activity = ActivityType._get_activity_type_by_name(name)
if activity:
return {'status': 'NameUsed'}
user = User._get_user_by_email(email)
if user:
ActivityType(name=name, user=user, uc_name=name.upper()).put()
return {'status': 'ActivityCreated'}
else:
return {'status': 'UserNotFound'}
示例3: get_user_activity_type_list
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import _get_user_by_email [as 别名]
def get_user_activity_type_list(email):
user = User._get_user_by_email(email)
if user:
query = ActivityType.all().filter('user =', user).filter('active =', True).order('-created_on')
activity_list = list()
for item in query.run():
activity_list.append({
'id': item.key().id(),
'name': item.name,
'created_on': item.created_on
})
return activity_list
return None
示例4: create_activity
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import _get_user_by_email [as 别名]
def create_activity(email, data):
user = User._get_user_by_email(email)
activity_type = ActivityType.get_by_id(int(data['activity_type']))
key = Activity(user=user, activity_type=activity_type, hours=data.get('hours', 0),
minutes=data.get('minutes', 0), seconds=data.get('seconds', 0)).put()
return {'status': 'ActivitySaved', 'id': key.id()}