Beispiel #1
0
def do_post(request):
    if request.method == "POST":
        form = TaskReportForm(request.POST)
        if form.is_valid():
            task_item_detail = form.cleaned_data["task_item_detail"]
            memo = form.cleaned_data["memo"]
            ymd = timezone.now()
            player_task = PlayerTask()
            player_task.task_item_detail = task_item_detail
            player_task.memo = memo
            player_task.task_ymd = ymd
            player_task.player = Player.objects.get(user__username=request.user.username)


            if check_task_save(request, task_item_detail):
                player_task.save()

                return redirect(urlresolvers.reverse_lazy('tasks:top'))
            else:
                return render_to_response('tasks/top.html',
                                          dict(form=form, player_task_list=get_player_task(request, timezone.now()),
                                               error_message="魔力が足りません"),
                                          RequestContext(request))

        else:
            return render_to_response('tasks/top.html',
                                      dict(form=form, player_task_list=get_player_task(request, timezone.now())),
                                      RequestContext(request))
Beispiel #2
0
def top(request):
    if request.method == "GET":
        form = TaskReportForm()

        return render_to_response('tasks/top.html',
                                  dict(form=form, player_task_list=get_player_task(request, timezone.now())),
                                  RequestContext(request))