コード例 #1
0
def check_biblio_tasks(request):
    if not request.user.is_authenticated():
        return HttpResponse(json.dumps({'Response':'Error: Must be logged in'}), status=403, content_type='application/json')
    if not verifyBibliocommonsAccount(request.user):
        return HttpResponse(json.dumps({'Response':'Error: Cant associate Bibliocommons user'}), status=400, content_type='application/json')
    activeTasks, otherTasks = matchingBibliocommonsTasks(request.user)
    beginDiscoveredTasks(request.user, otherTasks)

    for task in activeTasks:
        completeTask(request.user, task)
    for task in otherTasks:
        completeTask(request.user, task)
    return completedTasksHttpResponse(request.user, activeTasks, otherTasks)
コード例 #2
0
def submit_code_task(request):
    if not request.user.is_authenticated():
        return HttpResponse(json.dumps({'Response':'Error: Must be logged in'}), status=403, content_type='application/json')
    task = None
    if 'code' in request.GET:
        activeTasks, otherTasks = matchingCodeTasks(request.user, request.GET['code'])
    if len(activeTasks)+len(otherTasks) == 0:
        return HttpResponse(json.dumps({'Response':'Error: Expired or invalid code'}), status=400, content_type='application/json')
    beginDiscoveredTasks(request.user, otherTasks)
    for task in activeTasks:
        completeTask(request.user, task)
    for task in otherTasks:
        completeTask(request.user, task)
    return completedTasksHttpResponse(request.user, activeTasks, otherTasks)
コード例 #3
0
        return HttpResponse(json.dumps({'Response':'Error: Must be logged in'}), status=403, content_type='application/json')
    if request.method != 'POST':
        return HttpResponse(json.dumps({'Response':'Error: Bad state object'}), status=400)
    tlState = None
    try:
        tlState = json.loads(request.raw_post_data)
    except ValueError, e:
        print e
        print request.raw_post_data
        return HttpResponse(json.dumps({'Response':'Error: Bad state object'}), status=400)

    activeTasks, otherTasks = matchingTimeMapTasks(request.user, tlState)
    beginDiscoveredTasks(request.user, otherTasks)

    for task in activeTasks:
        completeTask(request.user, task)
    for task in otherTasks:
        completeTask(request.user, task)
    return completedTasksHttpResponse(request.user, activeTasks, otherTasks)

def submit_social_task(request):
    if not request.user.is_authenticated():
        return HttpResponse(json.dumps({'Response':'Error: Must be logged in'}), status=403, content_type='application/json')
    if request.method != 'POST':
        return HttpResponse(json.dumps({'Response':'Error: Bad state object'}), status=400)
    social = None
    try:
        social = json.loads(request.raw_post_data)
    except ValueError, e:
        print e
        return HttpResponse(json.dumps({'Response':'Error: Bad state object'}), status=400)