コード例 #1
0
ファイル: views.py プロジェクト: nghovi/mysite
def delete_book(request):
    # utils.dump(request.POST)
    pk = request.POST.get('id')
    deleted_book = Book.objects.get(pk=pk)
    deleted_book.delete();
    response = utils.build_json_obj_success(data=False)
    return JsonResponse(response)
コード例 #2
0
def delete_book(request):
    # utils.dump(request.POST)
    pk = request.POST.get('id')
    deleted_book = Book.objects.get(pk=pk)
    deleted_book.delete()
    response = utils.build_json_obj_success(data=False)
    return JsonResponse(response)
コード例 #3
0
def edit_task(request):
    new_task_string = request.POST.get('task')
    # logger.error(new_task_string)
    jtask = json.loads(new_task_string)
    date = datetime.strptime(jtask.get('date')[:-5], "%Y-%m-%d %H:%M:%S")
    last_update = datetime.strptime(
        jtask.get('lastupdated')[:-5], "%Y-%m-%d %H:%M:%S")
    primary_key = jtask.get("id")
    if (primary_key):
        new_task = Task(pk=primary_key,
                        name=jtask.get("name"),
                        description=jtask.get("description"),
                        status=jtask.get("status"),
                        priority=jtask.get("priority"),
                        date=date,
                        lastupdated=last_update)
    else:
        new_task = Task(name=jtask.get("name"),
                        description=jtask.get("description"),
                        status=jtask.get("status"),
                        priority=jtask.get("priority"),
                        date=date,
                        lastupdated=last_update)
    new_task.save()
    response = utils.build_json_obj_success(data=new_task.id)
    return JsonResponse(response)
コード例 #4
0
ファイル: views.py プロジェクト: nghovi/mysite
def delete_task(request):
    # utils.dump(request.POST)
    pk = request.POST.get('id')
    deleted_task = Task.objects.get(pk=pk)
    deleted_task.isDeleted = True;
    # deleted_task.delete();
    deleted_task.save();
    response = utils.build_json_obj_success(data=False)
    return JsonResponse(response)
コード例 #5
0
def delete_task(request):
    # utils.dump(request.POST)
    pk = request.POST.get('id')
    deleted_task = Task.objects.get(pk=pk)
    deleted_task.isDeleted = True
    # deleted_task.delete();
    deleted_task.save()
    response = utils.build_json_obj_success(data=False)
    return JsonResponse(response)
コード例 #6
0
ファイル: views.py プロジェクト: nghovi/mysite
def add_book(request):
    new_book_string = request.POST.get('book')
    logger.error(new_book_string)
    jbook = json.loads(new_book_string);
    link =  Link(url=jbook.get("link"), description="Link of book " + jbook.get("name"))
    link.save()
    updated_book = Book(booklink=link, name=jbook.get("name"), iconUrl=jbook.get("iconUrl"), author=jbook.get("author"),vocabulary=jbook.get("vocabulary"),comment=jbook.get("comment"),mood=jbook.get("mood"))
    updated_book.save()
    response = utils.build_json_obj_success(data=updated_book.id)
    return JsonResponse(response)
コード例 #7
0
ファイル: views.py プロジェクト: nghovi/mysite
def add_task(request):
    new_task_string = request.POST.get('task')
    # logger.error(new_task_string)
    jtask = json.loads(new_task_string);
    date = datetime.strptime(jtask.get('date')[:-5], "%Y-%m-%d %H:%M:%S")
    last_update= datetime.strptime(jtask.get('lastupdated')[:-5], "%Y-%m-%d %H:%M:%S")
    new_task = Task(name=jtask.get("name"), description=jtask.get("description"), status=jtask.get("status"),priority=jtask.get("priority"), date=date, lastupdated=last_update, isDeleted=False)
    new_task.save()
    response = utils.build_json_obj_success(data=new_task.id)
    return JsonResponse(response)
コード例 #8
0
def add_book(request):
    new_book_string = request.POST.get('book')
    logger.error(new_book_string)
    jbook = json.loads(new_book_string)
    link = Link(url=jbook.get("link"),
                description="Link of book " + jbook.get("name"))
    link.save()
    updated_book = Book(booklink=link,
                        name=jbook.get("name"),
                        iconUrl=jbook.get("iconUrl"),
                        author=jbook.get("author"),
                        vocabulary=jbook.get("vocabulary"),
                        comment=jbook.get("comment"),
                        mood=jbook.get("mood"))
    updated_book.save()
    response = utils.build_json_obj_success(data=updated_book.id)
    return JsonResponse(response)