[docs]defget_fields(scope,destination):""" .. :quickref: Import; Get synthesis fields. Get all synthesis fields Use in field mapping steps You can find a jsonschema of the returned data in the associated test. """data=[]entities=db.session.scalars(sa.select(Entity).filter_by(destination=destination).order_by(Entity.order)).all()forentityinentities:entity_fields=db.session.scalars(sa.select(EntityField).where(EntityField.entity==entity,EntityField.field.has(BibFields.display==True,),).join(BibThemes).order_by(BibThemes.order_theme,EntityField.order_field).options(selectinload(EntityField.field),selectinload(EntityField.theme))).all()themes=[]forid_theme,efsingroupby(entity_fields,lambdaef:ef.theme.id_theme):efs=list(efs)themes.append({"theme":efs[0].theme.as_dict(fields=["id_theme","name_theme","fr_label_theme","eng_label_theme","desc_theme",],),# Front retro-compat: we flatten entityfield and field"fields":[ef.as_dict(fields=["desc_field","comment",],)|ef.field.as_dict(fields=["id_field","name_field","fr_label","eng_label","mandatory","autogenerated","multi","mandatory_conditions","optional_conditions",])forefinefs],})data.append({"entity":entity.as_dict(fields=["label"]),"themes":themes,})returnjsonify(data)