Example #1
0
def interlink(request):
    item_info_json = request.json_body
    sync_status = item_info_json['sync_status']
    type = item_info_json['type']
    uuid =  item_info_json['item_uuid']
    log_id = item_info_json['log_id']
    remote_sync_info = None

    if sync_status == 'is_synced' or sync_status == 'was_synced':
        if type == 'log':
            log = Log.get_log_by_uuid(uuid)
            headers = {'content-type':'application/json'}
            url = 'http://poab.org:6544/sync?interlink=log'
            payload = {'log_json':json.dumps(log.reprJSON_extended())}
            remote_sync_info = requests.post(url, data=payload)
        if type == 'image':
            image = Image.get_image_by_uuid(uuid)
            print image
            headers = {'content-type':'application/json'}
            url = 'http://poab.org:6544/sync?interlink=image'
            payload = {'image_json':json.dumps(image.reprJSON_extended())}
            remote_sync_info = requests.post(url, data=payload)
        if type == 'track':
            track = Track.get_track_by_uuid(uuid)
            print track
            headers = {'content-type':'application/json'}
            url = 'http://poab.org:6544/sync?interlink=track'
            payload = {'track_json':json.dumps(track.reprJSON())}
            remote_sync_info = requests.post(url, data=payload)
    print remote_sync_info
    return Response(remote_sync_info.text)