Parse data from parltarck dossier export (1 dossier) Update dossier
    if it existed before, this function goal is to import and update a
    dossier, not to import all parltrack data

def parse_dossier_data(data, ep):
    """Parse data from parltarck dossier export (1 dossier) Update dossier
    if it existed before, this function goal is to import and update a
    dossier, not to import all parltrack data
    """
    changed = False
    doc_changed = False
    ref = data['procedure']['reference']

    logger.debug('Processing dossier %s', ref)

    with transaction.atomic():
        try:
            dossier = Dossier.objects.get(reference=ref)
        except Dossier.DoesNotExist:
            dossier = Dossier(reference=ref)
            logger.debug('Dossier did not exist')
            changed = True

        if dossier.title != data['procedure']['title']:
            logger.debug('Title changed from "%s" to "%s"', dossier.title,
                         data['procedure']['title'])
            dossier.title = data['procedure']['title']
            changed = True

        if changed:
            logger.info('Updated dossier %s', ref)
            dossier.save()

        source = data['meta']['source'].replace('&l=en', '')
        try:
            doc = Document.objects.get(dossier=dossier, kind='procedure-file')
        except Document.DoesNotExist:
            doc = Document(dossier=dossier, kind='procedure-file', chamber=ep)
            logger.debug('Document for dossier %s did not exist', ref)
            doc_changed = True

        if doc.link != source:
            logger.debug('Link changed from %s to %s', doc.link, source)
            doc.link = source
            doc_changed = True

        if doc_changed:
            logger.info('Updated document %s for dossier %s', doc.link, ref)
            doc.save()

    if 'votes' in data.keys() and 'epref' in data['votes']:
        command = Command()
        command.init_cache()
        command.parse_vote_data(data['votes'])