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

feat: add command to add cmd_to_add_type_site #334

Open
wants to merge 209 commits into
base: dev-suivi-eolien
Choose a base branch
from

Conversation

andriacap
Copy link
Contributor

Ajout de commande pour ajouter les types de sites (même principe que nomenclatures)

Reviewed-by: andriac

Maxime Vergez and others added 30 commits December 8, 2023 17:48
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
* feat(db): upgrade down_revision following rebase

Since rebase with develop: changed the down_revision number

* fix(db): fix bind params enabling downgrade

Beforehand the downgrade was not possible...

* refactor(db): removed cor_site_type_category

* refactor(db): changed category into type in cor

* refactor(db): create cor_type_site

* fix(db): renamed column

* refactor(api): update models to fit migrations

* fix(db):change bib_categorie_site to bib_type_site

Adding :
cor_site_module
cor_site_type
revision alembic to create function and trigger in order to add
bib_type_site but only with nomenclature 'TYPE_SITE'
upgrade and downgrade works

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

* fix(api): updated models from migrations

* fix(api): wip: fix admin following migrations

* fix(api): update routes and tests

To match migration changes

* feat: flask admin bib_type_site

Change bib_categories to bib_type_site into flask admin
Adding filtering in list label_fr of type_site to secure the unique
constraint

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

* fix(api): updated schema to match models

* fix(api): module edition

* style(api): uniformize type_site

* style(api): change relationship name for type_site

* feat(api): validator admin

* fix(api): make unique BibTypeSite in admin

* test(api): fix test when existing nomenclatures

In database

Co-authored-by: Andria Capai <[email protected]>
* 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

* perf(api): improved loading of modules

When there are loads of datasets, the relationship takes a lot of
time to load, and is useless for the route that uses it.

* fix: due to wrong rebase

Fix: newline on data_utils.py
Fix: relationships are not joined anymore since there is no need of
them
Chore: update comment
* fix(api): page - 1 that returned the wrong page

* test(api): add test for paginate
* fix(db): change trigger to constraint (migrations)

Delete the trigger and create check constraint on id_nomenclature column

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

* fix(db) : apply black on migration file

Apply black
[Refs_ticket]: #3
So that it will fallback to == most of the time and ilike when
just Unicode
Cannot use alembic to do this because need sqlalchemy >= 1.4.32
* refactor(api): change offset to page

* refactor(api): rename id_nomenclature

* fix(admin): add compare field to Unique

Since now, BibTypeSite and TNomenclature do not share the same
column anymore (id_nomenclature_type_site vs id_nomenclature)
* feat(db): upgrade down_revision following rebase

Since rebase with develop: changed the down_revision number

* fix(db): fix bind params enabling downgrade

Beforehand the downgrade was not possible...

* refactor(db): removed cor_site_type_category

* refactor(db): changed category into type in cor

* refactor(db): create cor_type_site

* fix(db): renamed column

* refactor(api): update models to fit migrations

* fix(db):change bib_categorie_site to bib_type_site

Adding :
cor_site_module
cor_site_type
revision alembic to create function and trigger in order to add
bib_type_site but only with nomenclature 'TYPE_SITE'
upgrade and downgrade works

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

* fix(api): updated models from migrations

* fix(api): wip: fix admin following migrations

* fix(api): update routes and tests

To match migration changes

* feat: flask admin bib_type_site

Change bib_categories to bib_type_site into flask admin
Adding filtering in list label_fr of type_site to secure the unique
constraint

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

* fix(api): updated schema to match models

* fix(api): module edition

* style(api): uniformize type_site

* style(api): change relationship name for type_site

* feat(api): validator admin

* fix(api): make unique BibTypeSite in admin

* test(api): fix test when existing nomenclatures

In database

Co-authored-by: Andria Capai <[email protected]>
* test(api): test all_geometries route

* feat(api): geojson instead of geobuf for sites

* feat(api): add all_sites_group_geometry route

To return the geometries of all sites groups

* test(api): refactor fixture

To add a new one: site_group_with_sites since not all sites_groups
have sites

* test(api): test get_sites_groups route

* feat(api): add possibility to filter

On id_base_site, base_site_name and id_sites_group

* test(api): add fixture to get group without site
* feat(front): wip sites_groups component and svc

* WIP feat(front): DataTable sites_groups

- Table with specific data value (OK)
- Table with sort column (OK)
- Datatable , select row event and change
color (wip).

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

* feat(front): Datatable format and selected row

- Get and display data from group_site database (OK)
- Selecting row and get id of row table (OK)

Improve :
- improve assign colname table outside the component (maybe into the
  class folder ?)

Todo/next:
- Filtering table
- Add action column to table
- refactor code by creating component for the ngx-datable in order to
  reuse component for other data

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

* feat(front): Filtering table (OK)

Function filtering is working on each column
Button filtering hide/display filter inputs (OK)

TODO:
- check for "help" icon and description for each column if description
  present
- Check if multiple rows and pages if it's working

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

* feat(front): wip server pagination & filtering

* feat(front): add sorting capability and fixes

Fix: keep filters (sort and filters) on when changing pages
Feat: remove useless id column
Feat: add sorting

* fix(db): change trigger to constraint (migrations)

Delete the trigger and create check constraint on id_nomenclature column

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

* refactor: Custom type Geojson and group properties

Create custom type geojson and build properties into marshmallow schema
according to this type of Geojson

[Refs ticket]: #3

* refactor: site component with site-service

add function to site.services.ts

[Refs ticket]: #4

* refactor: create datatable component and service

Separate of concern for all about table (service and component)
and all about sites (service and component)

reviewed_by: andriacap
[Refs ticket]: #3

* fix: change offset to page

change offset name to page
for paginated

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

* merge: merge interface and type

merge site_group.service.ts
delete site.service.ts
add interfaces
re arrange code from branch front-site-interface

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

* feat: details properties sites groups

Create properties components to display properties of sites_groups
Adding route with id according to the site group selected

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

* feat: display groups sites's child

Display group site child into table and uder properties
Use routing and id params to display property of groups site

Create service site
Add logic to check routing and child route to display reactive component
properties and table

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

* refactor(front): rename interfaces, remove classes

Better types

* feat(front): get all geometries

For sites and sites_groups

* feat(front): WIP: geojson service to create layers

And features groups since geojson component accumulated layers
without cleaning them...

* feat(front): implemented select capability

Need to refact a lot!

* feat(api): add route to get one site_group by id

* fix(front): too much /

* feat(front): add get sites_group from id

* fix(front): add possibility to provide Geometry

To setMapData

* refactor(front): sites and sites_groups component

To extend a base component to gather the same methods at one place
To use route children and router-outlet properly
To add some rxjs operators
To move some common interfaces/functions

* fix(front): fix filters by adding baseFilters

* feat: edit sitegroups

Create edit-service
Create observable to update object to edit according to form component
Adapt function service of monitoring object to sites and sitesgroups

WIP:
- adapt remaining function of monitoring object inside
form-component-g
- create an object which inherit of patch/post/delete method with
- think about object with ObjectType of sites_group , sites, observation
  ? , visit ?
- reload properties or update data of properties table after update data

Reviewed-by:andriacap
[Refs_ticket]: #4

* feat: edit sitegroups

Improving route 'patch'
Adding reload properties when sitegroups is updated
Refactoring EditService for more readability

Reviewed-by: andriacap
[Ref_ticket]: #4

* feat: improve edit

Add method to define objectType according to service used (site or
gpsite)

Rewied-by: andriacap
[Refs_ticket]: #4

* feat: improve rendering front "edit" and "add"

Adding global object service to set object type and
variable "add" or "edit" button

Reviewed-by: andriacap

[Refs_ticket]: #4

* feat: improving patch method object

Adding service to share request patch,get in order to to re-use the
service in form component according to the type pass inside the
formcomponent
Adding decorator errorhandler for blueprint routes

Reviewed-by:andriacap
[Refs_ticket]: #4

* feat: create site group method with form

Route create with form component
Using location pacakage to choose between edit form or init sitegroup
(see to improve that)

Rewiewed-by: andriacap
[Refs ticket]: #4

* feat: delete site_group component

Add route back
Add site_group from front form component

Reviewed-by:andriac
[Refs_ticket]: #4

* chore(api): removed unused code

* style(config): apply formatter

* chore(front): removed unused code & console.log

* feat(front): removed display map button

As it was ugly

* refactor(front): remove Object for keys

As there is an Angular pipe to get keys and values
Also removed console.log
Removed unused code

* style(front): reformat routes

* refactor(front): add create component

To isolate functionnalities

* chore(front): remove unused services

* chore(front): removed usused code

* chore(api): remove string package

And fix if that cannot be reached

* chore(api): removed unused comment

* chore(front): removed console.log and comments

* chore(api): removed unused code and log

---------

Co-authored-by: Andria Capai <[email protected]>
Hotfix because no compilable  with no existing component
and no existing function

Reviewed-by: andriacap
* refactor: object.service with observable obj

Change the objectType string to objectType obj
in order to subscribe to multilple properties link to this object

Reviewed-by: andriacap
[Refs_ticket]: #40

* feat: adapt service to get config json

Get fieldsName and fieldsLabel for display properties
(properties component)

Add logic to setItem in LocalStorage to keepLast Value of observable on reload page

TODO:
- [ ]  see if Localstorage is really necessary with the configService used inside api-geom.service )
- [ ] adapt monitoring-form-g.component with the new service

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

* feat: column datatable from config json

Add logic into sitegroups service in order to use config json to diplay
column datatable (called "display_list")

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

* feat: adjust backend to load config json

Adjust backend code to use existing code in order to load config from
file json and by starting with "sites_group"

Fix Media load and upload for site_group

TODO:
- [ ] check if config should be find from file or backend
- [ ] Optimize logic backend (use generic model with class method ?)

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

* feat: add button multiselect with filter on backend

filter with params backend (new route -> see if it's possible to change
that)

Add button multiselect above form type site

TODO:
- improve Input / condition of use case of btn multiselect

Reviewed-by: andriac

* feat: btn multiselect option

-Add @input fn , placeholder, title, paramsToFilt
-Remove empty option
-prevent adding from keyboard input or not including in list
-Store config json into object

Reviewed-by: @AndriaC
[Refs-ticket]: #4

* refactor: change form-service and object-service

refactor form-service
add observable into object-service (WIP: futur use for refresh page ?)

Rieviewed-by: andriac

[Refs_ticket]: #40

* refactor: test refresh page and comportment obs

refresh page seems to works with localstorage of different obj in
object_service

Reviewed-by: andriac

* feat: dynamic form

- Add:
- pass config json to form.component-g.ts
- add config json to this.obj and refresh form into form.component-g.ts
- add css for form component to deal when long form selected

-fix :
- refresh page form component (this._configService.init is necessary
  ...)
- comportment different between add or edit into form component and
  form service

Reviewed-by: andriac
[Refs_ticket]: #4

* feat: dynamic form - Correction PR

Remove unused console.log
Rxjs : use concatMap to avoid subscribe inside subscribe
Apply: prettier and sort prettier for import ts file

Reviewed-by: @AndriaC
[Refs_PR]: #42

* feat: dynamic create site

- Add change current-object when click "Add <object>" from datatable
  component
- api-geom.service: change the way to init the api-geom
- WIP:  two subscribes in one .. (the subscription is call only once ..)
- WIP : get config json from backend

Reviewed-by: andriac

* feat: add relationship id into sendData form site

Add type_site and id_site_group to the form site

Reviewed-by: andriac
[Refs_ticket]: #5 et #6

* feat(back): add custom config when post site

Change backend files in order to choose specific config when site is
created.

Reviewed-by: andriac
[Refs_ticket]: #5 , #6

* fix: problem of type object when loading form

Add endPoint and objectType to the observable using by the formservice
in order to use _apiGeomService with good context (endPoint)

[Refs_ticket]: #5 et #6

* fix: todo comments about refactoring code

Add todo comment in order to don't forget what
is to improve inside the code

* chore(front): add comment and remove console.log

* chore(api): put back old formatting

* chore(api): remove useless comment

* refactor(api): move and rename create_update fct

* fix: put back inventor/digitiser & fix typo

* chore: remove useless files

Since columns are now loaded from json, they are not needed
anymore in separate typescript files

* chore: remove definition from sites_group.json

* fix: column problem on sites

* chore: remove useless comment

* refactor(front): remove comment and use rxjs

* chore(front): remove useless file

Since class BtnMultiSelectChipClass is not used anymore

* chore(front): remove useless comments/imports

* style(front): applied prettier

* chore(front): remove useless code

* refactor(front): regroup types into an interface

* style(front): applied prettier

* refactor(front): inherit config-json from config

---------

Co-authored-by: Andria Capai <[email protected]>
amandine-sahl and others added 27 commits January 16, 2024 11:01
Passage à sqlalchemy 1.4 et ajout de tests
* Move create cor_type_site bib_type_site cor_module_type to geonature

* Remove id_nomenclature_type_site and migrate model to GeoNature

* Move t_observations to GeoNature

* Rename cor_type_site to cor_site_type

* Bump GeoNature
fix:  unify organism_actors behavior across models
* fix: remove relative imports and unused libs

* fix: remove unused modules

* Add import fixture monitoring_users

* Reorder imports

* Black

---------

Co-authored-by: Mathieu ROUDAUT <[email protected]>
Co-authored-by: amandine-sahl <[email protected]>
…I#292)

* fix: use table models migrated in geonature core

* fix: imports in tests files

* Import TNomenclature from pypnnomenclature

---------

Co-authored-by: Mathieu ROUDAUT <[email protected]>
Co-authored-by: amandine-sahl <[email protected]>
* Script sql de migration des permissions

* Changelog
* Correction url lien vers détail site 

* Harmonisation popup carto
* remove silented errors when insert in synthese 

* add migration for trigger delete in synthese
---------

Co-authored-by: amandine-sahl <[email protected]>
* allow multiple geom type

* Sites avec plusieurs type de géométrie par défaut

---------

Co-authored-by: amandine-sahl <[email protected]>
* Fix : migration modification for permissions
)

* feat: add test for config route

* feat: add data_utils tests

* fix: response code for data utils route

* fix: rename test to match source file

* fix: remove useless file

* fix: remove legacy code

* feat: add tests for utils and error
* Harmonisation des processus d'exécution de sql

* Add test forbidden sql instructions
@camillemonchicourt camillemonchicourt changed the base branch from dev-suivi-eolien to develop October 28, 2024 09:54
@camillemonchicourt camillemonchicourt changed the base branch from develop to dev-suivi-eolien October 28, 2024 09:55
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.

8 participants