本文整理汇总了Python中mygpo.users.models.User.get方法的典型用法代码示例。如果您正苦于以下问题:Python User.get方法的具体用法?Python User.get怎么用?Python User.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygpo.users.models.User
的用法示例。
在下文中一共展示了User.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def main(request, username):
""" API Endpoint for Device Synchronisation """
if request.method == 'GET':
return JsonResponse(get_sync_status(request.user))
else:
try:
actions = json.loads(request.raw_post_data)
except Exception as e:
return HttpResponseBadRequest(str(e))
synclist = actions.get('synchronize', [])
stopsync = actions.get('stop-synchronize', [])
try:
update_sync_status(request.user, synclist, stopsync)
except ValueError as e:
return HttpResponseBadRequest(str(e))
except DeviceDoesNotExist as e:
return HttpResponseNotFound(str(e))
# reload user to get current sync status
user = User.get(request.user._id)
return JsonResponse(get_sync_status(user))
示例2: _prepare_list
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def _prepare_list(self, l):
podcasts = Podcast.get_multi(l.podcasts[:self.podcasts_per_topic])
user = User.get(l.user)
l = proxy_object(l)
l.podcasts = podcasts
l.username = user.username
l.cls = "PodcastList"
return l
示例3: import_file
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def import_file(self, user_id, filename):
progress(0, 100, filename)
with open(filename, 'r') as f:
actions = json.load(f)
progress(0, len(actions), filename)
user = User.get(user_id)
now = datetime.now()
batch_size = 100
count = len(actions) / batch_size
for low in range(0, len(actions), batch_size):
high = low+batch_size
batch = actions[low:high]
update_episodes(user, batch, now, None)
progress(high, len(actions), filename)
示例4: _prepare_list
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def _prepare_list(l):
user = User.get(l.user)
l = proxy_object(l)
l.username = user.username
return l
示例5: get_user_by_id
# 需要导入模块: from mygpo.users.models import User [as 别名]
# 或者: from mygpo.users.models.User import get [as 别名]
def get_user_by_id(user_id):
from mygpo.users.models import User
try:
return User.get(user_id)
except ResourceNotFound:
return None