本文整理汇总了Python中frog.common.Result.value['tag']方法的典型用法代码示例。如果您正苦于以下问题:Python Result.value['tag']方法的具体用法?Python Result.value['tag']怎么用?Python Result.value['tag']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frog.common.Result
的用法示例。
在下文中一共展示了Result.value['tag']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: switchArtist
# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import value['tag'] [as 别名]
def switchArtist(request):
data = request.POST or json.loads(request.body)['body']
artist = data.get('artist', None)
guids = data.get('guids', '').split(',')
res = Result()
if artist:
if isinstance(artist, int):
author = User.objects.get(pk=artist)
tag = Tag.objects.get_or_create(name=author.get_full_name().lower(), defaults={'artist': True})[0]
else:
first, last = artist.lower().split(' ')
author = User.objects.get_or_create(first_name=first, last_name=last, defaults={
'username': '%s%s' % (first[0], last),
})[0]
tag = Tag.objects.get_or_create(name=artist.lower(), defaults={'artist': True})[0]
objects = getObjectsFromGuids(guids)
for n in objects:
n.author = author
n.tagArtist(tag)
res.append(userToJson(author))
res.value['tag'] = tag.id
return JsonResponse(res.asDict())
示例2: switchArtist
# 需要导入模块: from frog.common import Result [as 别名]
# 或者: from frog.common.Result import value['tag'] [as 别名]
def switchArtist(request):
artist = request.POST.get('artist', None)
guids = request.POST.get('guids', '').split(',')
res = Result()
if artist:
first, last = artist.lower().split(' ')
author = User.objects.get_or_create(first_name=first, last_name=last, defaults={
'username': '%s%s' % (first[0], last),
})[0]
tag = Tag.objects.get_or_create(name=artist.lower(), defaults={'artist': True})[0]
objects = getObjectsFromGuids(guids)
for n in objects:
n.author = author
n.tagArtist(tag)
res.isSuccess = True
res.append(userToJson(author))
res.value['tag'] = Tag.objects.get(name=artist.lower()).id
else:
res.isError = True
res.message = "No artist provided"
return JsonResponse(res)