예제 #1
0
파일: handler.py 프로젝트: hanxue/Potholes
 def create(self,request):
     data = request.data
     user = request.user
     player = Character.objects.get(player=user)
     action = Action.objects.get(id=data.get('action_id'))
     
     utils.give_point(player,action)
     utils.give_reward(player,action)
     return rc.CREATED
예제 #2
0
파일: views.py 프로젝트: hanxue/Potholes
def issue_upvote_list(request,id): 
    player = Character.objects.get(player=request.user)
    if not player.action:
        return HttpResponseRedirect('/issues/list/')
    issue = Issue.objects.get(id=id)
    issue.upvote = issue.upvote + 1
    issue.save()
    action = Action.objects.get(id=1)
    game_utils.give_point(player,action)
    game_utils.give_point(player,action)
    return HttpResponseRedirect('/issues/list')
예제 #3
0
파일: views.py 프로젝트: hanxue/Potholes
def issue_downvote(request,id):
    player = Character.objects.get(player=request.user)
    if not player.action:
        return HttpResponseRedirect('/issues/view/'+str(id))

    issue = Issue.objects.get(id=id)
    issue.downvote = issue.downvote + 1
    issue.save()
    action = Action.objects.get(id=1)
    game_utils.give_point(player,action)
    game_utils.give_point(player,action)

    return HttpResponseRedirect('/issues/view/'+str(id))
예제 #4
0
파일: views.py 프로젝트: hanxue/Potholes
def issue_submit(request):
    if request.method == 'POST': 
        user = request.user
        player = Character.objects.get(player=user)
        if not player.action:
            return HttpResponseRedirect('/issues/list/')
        form_data = request.POST
        title = form_data.get('title')
        description = form_data.get('description')
        location = form_data.get('location')
        img = request.FILES.get('img')
        
        issue = Issue()
        issue.title = title
        issue.description = description
        issue.location = location
        issue.image = img
        issue.user = user
        issue.save()
        
        if location:
            action = Action.objects.get(id=3)
            game_utils.give_point(player,action)
            game_utils.give_reward(player,action)
        
        if img:
            action = Action.objects.get(id=2)
            game_utils.give_point(player,action)
            game_utils.give_reward(player,action)

        return HttpResponseRedirect('/issues/list/')
    else:
        
        player = Character.objects.get(player=request.user)
        return render_to_response('issue_submit.html',{'player':player},
              context_instance=RequestContext(request))