Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev suivi eolien rebased on develop #238

Merged

Conversation

andriacap
Copy link

@andriacap andriacap commented Jul 24, 2023

Cette branche a été rebase par rapport à la branche branche develop de https://github.com/PnX-SI/gn_module_monitoring . Et a été installé sur le GN 2.13.0-beta1 (branche develop dernier commit : PnX-SI/GeoNature@652a7fd7b )

L'état de la PR est pour le moment en draft , car plusieurs soucis doivent être résolus :

  • Material Angular :

  • Détails des propriété des sites (composant monitoring-datatable , exemple l'ensemble des stations d'un circuit pour le module cheveches groupe de site):

    •  l'affichage de la liste des objets enfants apparait puis disparait --> source du problème trouvée : lors de l'entrée par protocoles c'est le fichier site.json du protcole qui est chargé , tandis que lors de l'entrée par site c'est le fichier site.Json du dossier generci qui est chargé . Les différences entre ces deux fichiers entraine des problèmes d'affichage notamment sur les filtres. ⚠️ Important voir comment uniformiser l'ajout et l'édition de site entre les deux entrées :
      • Plusieurs possibilités :
        - Checker les différences entre les champs "specific" / additionnels des deux fichiers de configs pour ne pas avertr / corriger ces différences ?
        - Ignorer les champs additionnels du fichier site.json du protocole et laisser la responsabilité d'affichage des champs additionnels liés aux types de site (associés au protocole en question)
  • Affichage des géométries:

    • les géométries des objets enfants (exemple l'ensemble des géométries stations pour le module cheveches groupe de site , ne s'affiche pas sur la carte) --> c'était lié au prolbème des différences de fichiers json site.json (voir explication ci dessus)
  • : Affichage des visites liées à un site (erreur sur les droits): voir issue [fix] Erreur de chargement de droits lors du chargement des visites lié à un site (entrée protocole) naturalsolutions/gn_module_monitoring#76 (Normalement OK dans les derniers commit de la branche develop de monitoring)

Retours sur le point réalisé avec @amandine-sahl et @joelclems :

  • Entrée par protocole: pouvoir à l'édition et création de site renseigner les types de site associés au protocole (voir l'utilisation de data_utils pour récupérer les types de site associés au module et insérer à la volé les champs specific + ajouter des attributs "hidden" en fonction du type sélectionné

  • Entrée par site : Rendre la possibilité d'ajouter un nouveau site sans groupe de site (mais laissé la possibilité d'ajouter le groupe de site une fois dans le formulaire)

  • Entrée par site : La géométrie n'est pas affichée à l'édition et à la visualisation d'un site

  • Rendre possible le filtre/sort du tableau sur le champ "type de site"

  • La liste des observers est renseigné dans le fichier de config du module moitoring et c'est celle ci qui est chargé par défault

  • L'enchainement des saisies avec des champs "keep" reste fonctionnel

    ⚠️ Le commit ba1a112 concerne la revision fc90d31c677fpour laquelle il a été ajouté des droits 'CUD' pour le module monitoring afin de pouvoir ajouter des types de site via le module Admin

@joelclems joelclems changed the base branch from dev-suivi-eolien to develop July 24, 2023 13:47
@andriacap andriacap force-pushed the dev-suivi-eolien-rebased branch 3 times, most recently from 5be029d to ae84016 Compare July 28, 2023 12:02
@andriacap andriacap force-pushed the dev-suivi-eolien-rebased branch 2 times, most recently from 0a4bf79 to 672d184 Compare August 23, 2023 09:19
@andriacap andriacap force-pushed the dev-suivi-eolien-rebased branch 2 times, most recently from 2850df2 to 1738b78 Compare September 7, 2023 16:17
Copy link
Contributor

@amandine-sahl amandine-sahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Première relecture des révisions

)
op.execute(statement)

# Drop column id_module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si il y a des modules installées avec des vues d'export qui utilisent id_module
sqlalchemy.exc.InternalError: (psycopg2.errors.DependentObjectsStillExist) cannot drop column id_module of table gn_monitoring.t_site_complements because other objects depend on it
A voir faire une note de version où gérer automatiquement la suppression des vues

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok ça marche je me le note dans un fichier de doc (en mettant note de version)

"bib_type_site",
"Table de définition des champs associés aux types de sites",
schema=monitorings_schema,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peupler la table avec les valeurs déjà présentes dans t_base_sites

INSERT INTO gn_monitoring.bib_type_site AS bts  (id_nomenclature_type_site)
SELECT DISTINCT id_nomenclature_type_site  
FROM gn_monitoring.t_base_sites AS tbs ;

"cor_type_site",
"Table d'association entre les sites et les types de sites",
schema=monitorings_schema,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peupler les données


INSERT INTO  gn_monitoring.cor_type_site
SELECT id_nomenclature_type_site , id_base_site d 
FROM gn_monitoring.t_base_sites ;

nullable=False,
),
sa.PrimaryKeyConstraint("id_type_site", "id_module", name="pk_cor_module_type"),
schema=monitorings_schema,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

upgrade data

INSERT INTO gn_monitoring.cor_module_type (id_module, id_type_site )
SELECT DISTINCT csm.id_module, cts.id_type_site
FROM gn_monitoring.cor_site_module AS csm
JOIN gn_monitoring.cor_type_site AS cts
ON Cts.id_base_site = csm.id_base_site ;

@@ -0,0 +1,36 @@
"""add_observers_txt_column_t_base_visit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doit être réalisé dans GN2 concomitamment avec le model

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concernant cette revision observers_txt" , tu dis que c'est coté GN ? Ca serait donc une revision avec un "depends_on" sur la premièe révision de la branche alembic monitorings ?

name=f"fk_{table}_{column}",
onupdate="CASCADE",
),
nullable=False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la colonne ne peut avoir la contrainte NOT NULL car il y a des données saisies et il n'est pas possible à 100% de retrouver l'id_digitizer

name=f"fk_{table}_{column}",
onupdate="CASCADE",
),
nullable=False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avant de rendre la colonne NOT NULL il faut peupler les données existantes à partir des visites

@codecov
Copy link

codecov bot commented Oct 10, 2023

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

return query


def geojson_query(subquery) -> bytes:
Copy link
Contributor

@amandine-sahl amandine-sahl Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette fonction ne peut pas fonctionner avec postgis < 3.0.0. Hors actuellement debian 10 est toujours supporté avec postgresql 11 et postgis 2.5

Maxime Vergez and others added 14 commits October 10, 2023 11:41
commit 70b0139
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 15:22:56 2022 +0100

    style: apply black

commit 2badedf
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 15:11:41 2022 +0100

    chore(db): removed unused import

commit 57d9b52
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 14:47:48 2022 +0100

    feat(db): improved & finished downgrade func

commit 211780f
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 09:32:12 2022 +0100

    feat(db): wip: add upgrade and began downgrade

    Downgrade migration need a little bit more work due to the use of
    sql alchemy and not plain text sql

commit 0b5a3b8
Author: Maxime Vergez <[email protected]>
Date:   Mon Dec 5 11:40:32 2022 +0100

    feat: packaged module
Squashed commit of the following:

commit 2bdc22a
Author: Maxime Vergez <[email protected]>
Date:   Fri Dec 9 14:59:31 2022 +0100

    chore: changed json_schema into config

commit 4279389
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 18:37:41 2022 +0100

    feat(db): add foreign key from site to cat

    From t_base_sites to bib_categorie_site

commit 5cb5dfa
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 16:47:27 2022 +0100

    feat(api): add admin interface

commit 559a0ec
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 16:46:27 2022 +0100

    feat(db): add bib_categorie_site table

    Add migration and model
…t description #2 (#15)

* feat: [6.2] Page d'accueil modul monitoring layout et config title et description #2

* chore(config): applied black & removed imports
* feat(api): wip began add site routes + tests

With site categories
Also add tests

* feat(api): add more routes

* test(api): add tests and fixtures

* style(api): applied black

* feat(db): add migration to remove id_module

Column in t_sites_groups

* refactor(api): move utils for routes from sites

* feat(api): wip: add sites groups route

* test(api): wip: begin adding fixture site_groups

* fix: remove id_module in all models

* chore: rename route for better consistency

* tests: moved site_groups in tests and add tests

* chore(api): applied black

* refactor(api): add filter params function

And refact routes to use it
* feat(api): add association table with alembic

Add model in backend and alembic migration

Reviewed-by: andriac
[Refs ticket]: #3

* test: WIP add test to see new relationship

Adding test to see if categories are showing up when we call module

Reviewed-by: andriacap
[Refs ticket]: #3

* feat: add type site - categorie relation

WIP - add selectfield to get type site in admin module

Reviewed-by: andriac
[Refs ticket]: #3

* feat(api): Flask admin and routes categories

Clean code for change label list and form selectfield for
the BibCategorieView in Flask Admin

Add utils routes to get all subtable relationship in order to
get back the label type site

Review-by: andriac
[Refs ticket]: #3

* refactor: remove paginate_nested

For depth in as_dict()

* test: fix tests due to as_dict depth

* style: applied black and isort

* chore: remove unused import

Co-authored-by: Andria Capai <[email protected]>
* tests: make tests and fixtures work for modules

By changing the way a monitoring module is created in the fixture
Add two tests to check the relationship

* feat(api): add categories in edit module

* style: applied black
Need to set the current working directory of pytest the directory
where the gn_monitoring_module repo is (so with the frontend etc.)
clean: Merge la PR move test_route 
Co-authored-by: Andria Capai <[email protected]>
* feat(api): remove id_module from sites_complements

Co-authored-by: andriacap <[email protected]>

* feat(api): create schema for sites_groups

* test: add sites_group to site fixture

* test: wip add test for sites_groups schemas

* chore(api): remove depth parameter from paginate

* test: updated to work with sites_group schema

* feat: categorie site with marshmallow

Test and marshmallow create/refactor to
adapt for bibcategorie site paginate

WIP : Adapt load_only site_type in test to "assert"
same object when initiate BibCategorieSite

[Refs ticket]: #3

* feat(api): route /sites/categories/id with schema

Changing the route to return a dump Marshmallow schema
BibCategorieSitesSchema

Reviewed-by: andriac
[Refs ticket]: #3

* test(api): routes get categoires label

Change the "as_dict" by schema.dump in order
to use the Marshmallow schema created

Reviewed-by: andriac
[Refs ticket]: #3

* feat(api): Sites: cols to geoserializable + schema

* style(api): applied black

* test(api): add test for Site Schema

* style(api): applied black to test_site

* refactor(api): instantiate schema once

Instead of for each all() iteration

* chore(api): remove useless comments

* chore(api): remove useless comments and imports

Co-authored-by: andriacap <[email protected]>
Co-authored-by: Andria Capai <[email protected]>
To replace it with a bib nomenclature type: TYPE_SITE
* fix(api): add int conversion for limit/offset

* test(api): add test for get_limit_offset

* fix(api): max_per_page => per_page & test

* test(api): update test with changes on schema

Since marshmallow schemas, the json returned by pagination has
changed for items and not sites
* feat(api): add Query Class to sites, grps & cats

* feat(api): add sort and fix _get_model

Via _get_entity

* test(api): test sort query

* feat(api): add api sort/sort_dir params

To be able to sort through REST Api

* fix(api): check if integer to avoid using ilike

In filter_by_params

* test(api): add test to check filter integer
* Merged feat/package-module-alembic

commit 70b0139
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 15:22:56 2022 +0100

    style: apply black

commit 2badedf
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 15:11:41 2022 +0100

    chore(db): removed unused import

commit 57d9b52
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 14:47:48 2022 +0100

    feat(db): improved & finished downgrade func

commit 211780f
Author: Maxime Vergez <[email protected]>
Date:   Tue Dec 6 09:32:12 2022 +0100

    feat(db): wip: add upgrade and began downgrade

    Downgrade migration need a little bit more work due to the use of
    sql alchemy and not plain text sql

commit 0b5a3b8
Author: Maxime Vergez <[email protected]>
Date:   Mon Dec 5 11:40:32 2022 +0100

    feat: packaged module

* Feat/edit categories module (#19)

* tests: make tests and fixtures work for modules

By changing the way a monitoring module is created in the fixture
Add two tests to check the relationship

* feat(api): add categories in edit module

* style: applied black

* fix(config): changed categories into items

Following the change with marshmallow schemas
andriacap and others added 19 commits October 10, 2023 16:51
Basé sur les retours de Camille, Amandine et MNHN

Reviewed-by: andriac
Reviewed-by: andriacap
Reset specific field when quit form component (entrance through site)

Reviewed-by: andriac
Load permission on 'ALL' for modules error . Change to precise object
visit permission

Reviewed-by: andriac
Reviewed-by: andriacap
Reviewed-by: andriac
Manage geometry site group (load, reload, on cancel, manage layer etc) (entrance through site)

Reviewed-by: andriac
Allow user to create and edit geometry for site group

Case :
- site group with child --> if no geom created, geometry is
  calculated
  --> if geom created you can edit this geom
- site group without child --> geom can be null (otherwise it's possible
  to create geom)

- Remove console.log

Reviewed-by: andriacap
Add message about geometry site group to infomr user that the current
geometry is calculated based on site group's child

Reviewed-by: andriacap
Error on check id_organism compare to organism actor

Reviewed-by: andriacap
Creation d'un nouveau fichier pour expliquer l'entrée par groupe de
site et site
Modification de la présentation du module monitoring
Modification du paragraphe de Permissions
Ajout d'images descriptives

Reviewed-by: andriacap
Add part to explain link between type site field in edit and creation site form

Reviewed-by: andriacap
- Fix bug changeActiveTab
- Add displaying conditional site group geometry through protocol

Reviewed-by: andriacap
Reviewed-by: andriacap
Error when using docker build

Reviewed-by: andriacap
@amandine-sahl amandine-sahl marked this pull request as ready for review December 8, 2023 11:22
@amandine-sahl amandine-sahl merged commit c710880 into PnX-SI:dev-suivi-eolien Dec 8, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants