def addcard(request, card):
if request.method != "POST":
raise PermissionDenied()
collection = 'collection' in request.GET
queryset = Card
if not collection:
# Note: calling filterCards will add extra info need to display the card
queryset = filterCards(Card.objects.all(), {}, request)
card = get_object_or_404(queryset, pk=card)
account = get_object_or_404(Account, pk=request.POST.get('account', None), owner=request.user)
OwnedCard.objects.create(card=card, account=account, evolved=card.evolvable, level=card.max_level)
OwnedCard.objects.get(card=card, account=account).force_cache_stats()
if not collection:
card.total_owned += 1
if collection:
return cardcollection(request, card.id)
else:
context = web_globalContext(request)
return item_view(request, context, 'card', CardCollection, pk=card.id, item=card, ajax=True)
评论列表
文章目录