def create_dataset_user(user): """ After dataset validation, add a personnal AF and JDD so the user can add new user. """ af_desc_and_name = "Cadre d'acquisition personnel de {name} {surname}".format( name=user["nom_role"], surname=user["prenom_role"]) # actor = data productor af_productor = CorAcquisitionFrameworkActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "6"), ) af_contact = CorAcquisitionFrameworkActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "1"), ) new_af = TAcquisitionFramework( acquisition_framework_name=af_desc_and_name, acquisition_framework_desc=af_desc_and_name + " - auto-créé via la demande de création de compte", acquisition_framework_start_date=datetime.datetime.now(), ) new_af.cor_af_actor = [af_productor, af_contact] DB.session.add(new_af) DB.session.commit() ds_desc_and_name = "Jeu de données personnel de {name} {surname}".format( name=user["nom_role"], surname=user["prenom_role"]) ds_productor = CorDatasetActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "6"), ) ds_contact = CorDatasetActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "1"), ) # add new JDD: terrestrial and marine = True as default new_dataset = TDatasets( id_acquisition_framework=new_af.id_acquisition_framework, dataset_name=ds_desc_and_name, dataset_shortname=ds_desc_and_name + " - auto-créé via la demande de création de compte", dataset_desc=ds_desc_and_name, marine_domain=True, terrestrial_domain=True, ) new_dataset.cor_dataset_actor = [ds_productor, ds_contact] DB.session.add(new_dataset) DB.session.commit()
def create_dataset_user(user): """ After dataset validation, add a personnal AF and JDD so the user can add new user. """ af_desc_and_name = "Cadre d'acquisition personnel de {name} {surname}".format( name=user["nom_role"], surname=user["prenom_role"]) # actor = data productor af_productor = CorAcquisitionFrameworkActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "6"), ) af_contact = CorAcquisitionFrameworkActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "1"), ) new_af = TAcquisitionFramework( acquisition_framework_name=af_desc_and_name, acquisition_framework_desc=af_desc_and_name + " - auto-créé via la demande de création de compte", acquisition_framework_start_date=datetime.datetime.now(), ) new_af.cor_af_actor = [af_productor, af_contact] db.session.add(new_af) ds_desc_and_name = "Jeu de données personnel de {name} {surname}".format( name=user["nom_role"], surname=user["prenom_role"]) ds_productor = CorDatasetActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "6"), ) ds_contact = CorDatasetActor( id_role=user["id_role"], id_nomenclature_actor_role=func.ref_nomenclatures.get_id_nomenclature( "ROLE_ACTEUR", "1"), ) # add new JDD: terrestrial and marine = True as default new_dataset = TDatasets( acquisition_framework=new_af, dataset_name=ds_desc_and_name, dataset_shortname=ds_desc_and_name + " - auto-créé via la demande de création de compte", dataset_desc=ds_desc_and_name, marine_domain=True, terrestrial_domain=True, ) new_dataset.cor_dataset_actor = [ds_productor, ds_contact] db.session.add(new_dataset) for module_code in current_app.config['ACCOUNT_MANAGEMENT'][ 'DATASET_MODULES_ASSOCIATION']: module = TModules.query.filter_by( module_code=module_code).one_or_none() if module is None: warn("Module code '{}' does not exist, can not associate dataset.". format(module_code)) continue new_dataset.modules.append(module) db.session.commit()