コード例 #1
0
ファイル: views.py プロジェクト: an/GTGOnline
def get_details(request):
    task_id = request.GET.get('id', -1)
    get_log = request.GET.get('log', '0')
    
    task = get_task_object(request.user, task_id)
    details = []
    if task != None and task.shared_with.exists():
        details = get_shared_task_details(task)
    return HttpResponse(json.dumps(details, indent = 4), \
                        mimetype = 'application/json')
コード例 #2
0
ファイル: views.py プロジェクト: an/GTGOnline
def delete_task(request):
    folder = request.GET.get('folder', 'Active')
    
    task_id_list = request.GET.getlist('task_id_list[]')
    params = QueryDict(request.body, request.encoding)
    #print >>sys.stderr, "Params = " + str(params == {})
    
    query_is_from_client = True
    if params != {}:
        query_is_from_client = False
        api_key = params.get('api_key', None)
        #password = params.get('password', None)
        user = get_user_from_api_key(api_key)
        if user == None:
            return HttpResponse(json.dumps('0', indent=4), \
                                mimetype='application/json')
        task_id_list = json.loads(params.get("task_id_list", ""))
    else:
        user = request.user
    
    if task_id_list != []:
        for task_id in task_id_list:
            task = get_task_object(user, task_id)
            if task != None:
                delete_task_tree(user, task)
                delete_single_task(user, task)
    else:
        task_id = request.GET.get('task_id', -1)
        print >>sys.stderr, task_id
        if task_id != '-1':
            task = get_task_object(request.user, task_id)
            if task != None:
                delete_task_tree(request.user, task)
                delete_single_task(request.user, task)
    if not query_is_from_client:
        return HttpResponse(json.dumps('1', indent=4), \
                        mimetype='application/json')
    return HttpResponseRedirect('/tasks/get/?folder=' + folder)