(request, domain)
return HttpResponse(status=200)
Allows a user to claim a case that they don't own.
Allows a user to claim a case that they don't own.
Allows a user to claim a case that they don t own .
def claim(request, domain):
    """
    Allows a user to claim a case that they don't own.
    """
    as_user = unquote(request.POST.get('commcare_login_as', ''))
    as_user_obj = CouchUser.get_by_username(as_user) if as_user else None
    restore_user = get_restore_user(domain, request.couch_user, as_user_obj)

    case_id = unquote(request.POST.get('case_id', ''))
    if not case_id:
        return HttpResponse('A case_id is required', status=400)

    try:
        if get_first_claim(domain, restore_user.user_id, case_id):
            return HttpResponse('You have already claimed that {}'.format(request.POST.get('case_type', 'case')),
                                status=409)

        claim_case(domain, restore_user, case_id,
                   host_type=unquote(request.POST.get('case_type', '')),
                   host_name=unquote(request.POST.get('case_name', '')),
                   device_id=__name__ + ".claim")
    except CaseNotFound:
        return HttpResponse('The case "{}" you are trying to claim was not found'.format(case_id),
                            status=410)
    return HttpResponse(status=200)
def claim ( request , domain ) : as_user = unquote ( request . POST . get ( 'commcare_login_as' , '' ) ) as_user_obj = CouchUser . get_by_username ( as_user ) if as_user else None restore_user = get_restore_user ( domain , request . couch_user , as_user_obj ) case_id = unquote ( request . POST . get ( 'case_id' , '' ) ) if not case_id : return HttpResponse ( 'A case_id is required' , status = 400 ) try : if get_first_claim ( domain , restore_user . user_id , case_id ) : return HttpResponse ( 'You have already claimed that {}' . format ( request . POST . get ( 'case_type' , 'case' ) ) , status = 409 ) claim_case ( domain , restore_user , case_id , host_type = unquote ( request . POST . get ( 'case_type' , '' ) ) , host_name = unquote ( request . POST . get ( 'case_name' , '' ) ) , device_id = __name__ + ".claim" ) except CaseNotFound : return HttpResponse ( 'The case "{}" you are trying to claim was not found' . format ( case_id ) , status = 410 ) return HttpResponse ( status = 200 )