def ocr_pdf_attachment(att):
    if att.converted:
        ocred_att = att.converted
    else:
        (name, ext) = os.path.splitext(att.name)
        name = _('{name}_ocr{ext}').format(name=name, ext='.pdf')
        ocred_att = FoiAttachment.objects.create(name=name, belongs_to=att.belongs_to, approved=False, filetype='application/pdf', is_converted=True, can_approve=att.can_approve)
    att.converted = ocred_att
    att.can_approve = False
    att.approved = False
    att.save()
    ocr_pdf_task.delay(att.pk, ocred_att.pk)
def ocr_pdf_attachment(att):
    if att.converted:
        ocred_att = att.converted
    else:
        (name, ext) = os.path.splitext(att.name)
        name = _('{name}_ocr{ext}').format(name=name, ext='.pdf')
        ocred_att = FoiAttachment.objects.create(name=name, belongs_to=att.belongs_to, approved=False, filetype='application/pdf', is_converted=True, can_approve=att.can_approve)
    att.converted = ocred_att
    att.can_approve = False
    att.approved = False
    att.save()
    ocr_pdf_task.delay(att.pk, ocred_att.pk)