def del_interactive_update(request):
    rs = remindstore()
    list1 = []
    list2 = []
    if request.POST.get('_id'):
        info = rs.del_item(request.POST.get('_id'),request.POST.get('_record_id'),request.POST.get('_user_id'),request.POST.get('_ismultiple'))
    elif request.POST.get('data_str'):
        list1 = request.POST.get('data_str').split('#')
        for list1_ele in list1:
            if list1_ele:
                list2 = list1_ele.split(',')
                info = rs.del_item(list2[0],list2[1],list2[2],list2[3])
    return utils.JsonResponse({})    
def save_interactive_update(request):
    rs = remindstore()
    info = json.loads(request.POST.get('info'))
    info['date'] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%fZ')
    user_id = str(info['user_id']).split(',')
    if len(user_id)>1:
        '''
        for v in user_id:
            singleInfo = info.copy()
            singleInfo['user_id'] = v
            rs.insert_item(singleInfo)
        '''
        info['user_id']=user_id
        rs.insert_item(info)
    else:
        rs.insert_item(info)
    return utils.JsonResponse({'results':'true'})
def set_interactive_update(request):
    rs = remindstore()
    #info = rs.set_item(request.POST.get('_id'),request.POST.get('_name'),request.POST.get('_value'))
    info = rs.set_item(request.POST.get('_id'),request.POST.get('_name'),request.POST.get('_value'),request.POST.get('_user_id'),request.POST.get('_record_id'),request.POST.get('_ismultiple'))
    return utils.JsonResponse({})
def get_interactive_update_range(request):
    rs = remindstore()
    count = rs.get_total(str(request.user.id))
    info  = rs.return_items(str(request.user.id),int(request.POST.get('skip')),int(request.POST.get('limit')))
    return utils.JsonResponse({'results': info,'count': count})
def get_interactive_update(request):
    rs = remindstore()
    rs.createGlobalInfo(str(request.user.id))
    count = rs.items_count(str(request.user.id))
    info  = rs.return_items(str(request.user.id))
    return utils.JsonResponse({'results': info,'count': count})