本文整理匯總了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