コード例 #1
0
ファイル: views.py プロジェクト: jerzyKleszcz/simtechBackend
def unwear(request):
    """Undress user's avatar"""
    student = Student.objects.get(user=request.user)
    avatar = Avatar.objects.get(student=student)
    Wearing(avatar=avatar).objects.get(item=item_to_wear).delete()
    Wearing(avatar=avatar).slot = Wearing(avatar=avatar).slot - 1
    Wearing.save()
    return HttpResponse('')
コード例 #2
0
ファイル: views.py プロジェクト: jerzyKleszcz/simtechBackend
def wear(request):
    """Dress user's avatar in selected piece of cloth"""
    student = Student.objects.get(user=request.user)
    avatar = Avatar.objects.get(student=student)
    number_wearing = Wearing(avatar = avatar).objects.annotate(number_of_items=Count('slot'))
    if number_wearing < 10:
        Wearing(avatar=avatar).objects.append(item = item_to_wear)
        Wearing(avatar=avatar).slot = Wearing(avatar=avatar).slot + 1
        Wearing.save()
        return HttpResponse('')

    else:
        return HttpResponse('Already wearing maximum number of items')