Esempio n. 1
0
 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
Esempio n. 2
0
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')
Esempio n. 3
0
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))
Esempio n. 4
0
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))