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/individuals rebased #402

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/gn_module_monitoring/command/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"MONITORINGS_GRP_SITES": {"label": "groupes de sites", "actions": ["C", "R", "U", "D"]},
"MONITORINGS_SITES": {"label": "sites", "actions": ["C", "R", "U", "D"]},
"MONITORINGS_VISITES": {"label": "visites", "actions": ["C", "R", "U", "D"]},
"MONITORINGS_INDIVIDUALS": {"label": "individus", "actions": ["C", "R", "U", "D"]},
"MONITORINGS_MARKINGS": {"label": "marquages", "actions": ["C", "R", "U", "D"]},
}

ACTION_LABEL = {
Expand Down
2 changes: 2 additions & 0 deletions backend/gn_module_monitoring/conf_schema_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"visit": "MONITORINGS_VISITES",
"observation": "MONITORINGS_VISITES",
"observation_detail": "MONITORINGS_VISITES",
"individual": "MONITORINGS_INDIVIDUALS",
"marking": "MONITORINGS_MARKINGS",
}


Expand Down
1 change: 1 addition & 0 deletions backend/gn_module_monitoring/config/generic/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"observer_list": "nom_liste",
"taxonomy": "__MODULE.TAXONOMY_DISPLAY_FIELD_NAME",
"taxonomy_list": "nom_liste",
"cd_nom": "cd_nom",
"sites_group": "sites_group_name",
"habitat": "lb_hab_fr",
"area": "area_name",
Expand Down
90 changes: 90 additions & 0 deletions backend/gn_module_monitoring/config/generic/individual.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"id_field_name": "id_individual",
"description_field_name": "individual_name",
"chained": true,
"filters": {
"active": true
},
"label": "Individu",
"genre": "M",
"display_properties": ["uuid_individual",
"individual_name",
"active",
"id_nomenclature_sex",
"comment",
"cd_nom",
"id_digitiser",
"id_operator"
],
"display_list": [
"individual_name",
"uuid_individual",
"active",
"nb_sites"
],
"uuid_field_name": "uuid_individual",
"generic": {
"id_individual": {
"type_widget": "text",
"attribut_label": "Id individual",
"hidden": true
},
"nb_sites": {
"attribut_label": "Nombre de sites associés"
},
"uuid_individual": {
"attribut_label": "uuid"
},
"individual_name": {
"type_widget": "text",
"attribut_label": "Nom de l'individu",
"required": true
},
"id_nomenclature_sex": {
"type_widget": "nomenclature",
"attribut_label": "Sexe",
"code_nomenclature_type": "SEXE",
"type_util": "nomenclature"
},
"active": {
"type_widget": "bool_checkbox",
"attribut_label": "Actif",
"definition": "Activer cet individu",
"value": true
},
"comment": {
"type_widget": "textarea",
"attribut_label": "Commentaires"
},
"cd_nom": {
"type_widget": "taxonomy",
"attribut_label": "Espèce",
"type_util": "taxonomy",
"id_list": "__MODULE.ID_LIST_TAXONOMY",
"required": "({value}) => '__MODULE.CD_NOM' === 'None'",
"hidden": "({value}) => '__MODULE.CD_NOM' !== 'None'"
},
"id_digitiser": {
"type_widget": "text",
"attribut_label": "Numérisateur",
"required": true,
"hidden": true,
"type_util": "user"
},
"medias": {
"type_widget": "medias",
"attribut_label": "Médias",
"schema_dot_table": "gn_monitoring.t_marking_events"
}
},
"change": [
"({objForm, meta}) => {",
"const cd_nom = __MODULE.CD_NOM",
"if (!objForm.controls.cd_nom.dirty) {",
"objForm.patchValue({cd_nom: cd_nom})",
"}",
"}",
""
]
}

89 changes: 89 additions & 0 deletions backend/gn_module_monitoring/config/generic/marking.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"id_field_name": "id_marking",
"description_field_name": "id_marking",
"chained": true,
"label": "Marquage",
"genre": "M",
"display_properties": [
"marking_location",
"marking_code",
"marking_details"
],
"display_list": [
"marking_location",
"marking_code",
"marking_details",
"id_nomenclature_marking_type",
"id_base_marking_site",
"id_operator"
],
"uuid_field_name": "id_marking",
"generic": {
"id_marking": {
"type_widget": "text",
"attribut_label": "Id marquage",
"hidden": true
},
"id_individual": {
"type_widget": "individuals",
"attribut_label": "Choix de l'individu",
"id_module": "__MODULE.ID_MODULE",
"hidden": true
},
"marking_date": {
"type_widget": "date",
"attribut_label": "Date de marquage",
"required": true
},
"id_operator": {
"type_widget": "datalist",
"attribut_label": "Opérateur",
"api": "users/menu/__MODULE.ID_LIST_OBSERVER",
"application": "GeoNature",
"keyValue": "id_role",
"keyLabel": "nom_complet",
"type_util": "user",
"required": true
},
"id_base_marking_site": {
"type_widget": "datalist",
"attribut_label": "Site",
"type_util": "site",
"keyValue": "id_base_site",
"keyLabel": "base_site_name",
"api": "__MONITORINGS_PATH/list/__MODULE.MODULE_CODE/site?id_module=__MODULE.ID_MODULE&fields=id_base_site&fields=base_site_name",
"application": "GeoNature"
},
"id_nomenclature_marking_type": {
"type_widget": "nomenclature",
"attribut_label": "Type de marquage",
"code_nomenclature_type": "TYP_MARQUAGE",
"type_util": "nomenclature",
"required": true
},
"marking_location": {
"type_widget": "text",
"attribut_label": "Localisation du marquage"
},
"marking_code": {
"type_widget": "text",
"attribut_label": "Code du marquage"
},
"marking_details": {
"type_widget": "text",
"attribut_label": "Détails du marquage"
},
"id_digitiser": {
"type_widget": "text",
"attribut_label": "Numérisateur",
"required": true,
"hidden": true,
"type_util": "user"
},
"medias": {
"type_widget": "medias",
"attribut_label": "Médias",
"schema_dot_table": "gn_monitoring.t_marking_events"
}
}
}
10 changes: 7 additions & 3 deletions backend/gn_module_monitoring/config/generic/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@
"definition": "Affichage des groupes de site en dessinant l'enveloppe des sites du groupe et en affichant l'aire du groupe de sites",
"hidden": true
},


"taxonomy_display_field_name": {
"type_widget": "datalist",
"attribut_label": "Affichage des taxons",
Expand All @@ -116,7 +114,13 @@
"required": true,
"designStyle": "bootstrap"
},

"cd_nom": {
"type_widget": "taxonomy",
"attribut_label": "Espèce",
"type_util": "taxonomy",
"required": false,
"hidden": true
},
"active_frontend": {
"type_widget": "bool_checkbox",
"attribut_label": "Afficher dans le menu ?",
Expand Down
12 changes: 10 additions & 2 deletions backend/gn_module_monitoring/config/generic/observation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"chained": true,
"label": "Observation",
"genre": "F",
"display_properties": ["cd_nom", "comments"],
"display_properties": [
"cd_nom",
"comments"
],
"uuid_field_name": "uuid_observation",
"generic": {
"id_observation": {
Expand All @@ -24,6 +27,11 @@
"hidden": true,
"type_util": "user"
},
"id_individual": {
"type_widget": "text",
"attribut_label": "Id individu",
"hidden": true
},
"cd_nom": {
"type_widget": "taxonomy",
"attribut_label": "Espèce",
Expand All @@ -44,4 +52,4 @@
"schema_dot_table": "gn_monitoring.t_observations"
}
}
}
}
14 changes: 11 additions & 3 deletions backend/gn_module_monitoring/config/generic/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"genre": "M",
"geom_field_name": "geom",
"uuid_field_name": "uuid_base_site",
"geometry_type": ["Point", "LineString", "Polygon"],
"geometry_type": [
"Point",
"LineString",
"Polygon"
],
"display_properties": [
"base_site_name",
"base_site_code",
Expand All @@ -25,7 +29,8 @@
"last_visit",
"id_inventor",
"nb_visits",
"types_site"
"types_site",
"nb_individuals"
],
"sorts": [
{
Expand Down Expand Up @@ -80,6 +85,9 @@
"nb_visits": {
"attribut_label": "Nb. visites"
},
"nb_individuals": {
"attribut_label": "Nb. individus"
},
"uuid_base_site": {
"attribut_label": "uuid"
},
Expand Down Expand Up @@ -115,4 +123,4 @@
"required": false
}
}
}
}
1 change: 1 addition & 0 deletions backend/gn_module_monitoring/config/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def get_config(module_code=None, force=False):
"b_draw_sites_group",
"taxonomy_display_field_name",
"id_module",
"cd_nom",
]:
var_name = "__MODULE.{}".format(field_name.upper())
config["custom"][var_name] = getattr(module, field_name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""[individuals] add cd_nom t_module_complements

Revision ID: 398f94b364f7
Revises: 6f90dd1aaf69
Create Date: 2023-12-20 13:52:18.563621

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "398f94b364f7"
down_revision = "6f90dd1aaf69"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
schema="gn_monitoring",
table_name="t_module_complements",
column=sa.Column(
"cd_nom",
sa.Integer,
),
)


def downgrade():
op.drop_column(
schema="gn_monitoring",
table_name="t_module_complements",
column_name="cd_nom",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""[individuals] add individual permissions

Revision ID: 461b82ee737a
Revises: 398f94b364f7
Create Date: 2023-11-21 14:14:48.084725

"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "461b82ee737a"
down_revision = "398f94b364f7"
branch_labels = None
depends_on = None


def upgrade():
op.execute(
"""
INSERT INTO gn_permissions.t_objects (code_object, description_object)
VALUES ('MONITORINGS_INDIVIDUALS', 'Permissions sur les individus'),
('MONITORINGS_MARKINGS', 'Permissions sur les marquages');
"""
)


def downgrade():
op.execute(
"""
DELETE FROM gn_permissions.t_permissions WHERE id_object in
(SELECT id_object FROM gn_permissions.t_objects WHERE code_object in ('MONITORINGS_INDIVIDUALS', 'MONITORINGS_MARKINGS'))
"""
)
op.execute(
"""
DELETE FROM gn_permissions.t_permissions_available WHERE id_object in
(SELECT id_object FROM gn_permissions.t_objects WHERE code_object in ('MONITORINGS_INDIVIDUALS', 'MONITORINGS_MARKINGS'))
"""
)
op.execute(
"""
DELETE FROM gn_permissions.t_objects where code_object in ('MONITORINGS_INDIVIDUALS', 'MONITORINGS_MARKINGS');
"""
)
Loading
Loading