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

Améliorations de la commande d’installation des modules #3261

Open
wants to merge 6 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
3 changes: 2 additions & 1 deletion backend/geonature/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def set_sentry_context():
current_app.config["DISABLED_MODULES"].append(module_code)
else:
module_blueprint.config = config[module_code]
app.register_blueprint(module_blueprint, url_prefix=f"/{module_code.lower()}")
url_prefix = current_app.config[module_code]["MODULE_API"]
app.register_blueprint(module_blueprint, url_prefix=url_prefix)

return app
41 changes: 23 additions & 18 deletions backend/geonature/core/command/create_gn_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,33 @@
raise ClickException(
f"Impossible de détecter le code du module, essayez de le spécifier."
)
# symlink module in exernal module directory

module_frontend_path = (module_path / "frontend").resolve()
module_symlink = ROOT_DIR / "frontend" / "external_modules" / module_code.lower()
if os.path.exists(module_symlink):
if module_frontend_path != os.readlink(module_symlink):
click.echo(f"Correction du lien symbolique {module_symlink} → {module_frontend_path}")
os.unlink(module_symlink)
if module_frontend_path.exists(): # check that the module provides a frontend
# symlink module in exernal module directory
module_symlink = ROOT_DIR / "frontend" / "external_modules" / module_code.lower()
if os.path.exists(module_symlink):
if module_frontend_path != os.readlink(module_symlink):
click.echo(

Check warning on line 88 in backend/geonature/core/command/create_gn_module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/command/create_gn_module.py#L85-L88

Added lines #L85 - L88 were not covered by tests
f"Correction du lien symbolique {module_symlink} → {module_frontend_path}"
)
os.unlink(module_symlink)
os.symlink(module_frontend_path, module_symlink)

Check warning on line 92 in backend/geonature/core/command/create_gn_module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/command/create_gn_module.py#L91-L92

Added lines #L91 - L92 were not covered by tests
else:
click.echo(f"Création du lien symbolique {module_symlink} → {module_frontend_path}")

Check warning on line 94 in backend/geonature/core/command/create_gn_module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/command/create_gn_module.py#L94

Added line #L94 was not covered by tests
os.symlink(module_frontend_path, module_symlink)
else:
click.echo(f"Création du lien symbolique {module_symlink} → {module_frontend_path}")
os.symlink(module_frontend_path, module_symlink)
if (Path(module_path) / "frontend" / "package-lock.json").is_file():
click.echo("Installation des dépendances frontend…")
install_frontend_dependencies(module_frontend_path)
if (Path(module_path) / "frontend" / "package-lock.json").is_file():
click.echo("Installation des dépendances frontend…")
install_frontend_dependencies(module_frontend_path)

Check warning on line 98 in backend/geonature/core/command/create_gn_module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/command/create_gn_module.py#L96-L98

Added lines #L96 - L98 were not covered by tests

click.echo("Création de la configuration frontend…")
create_frontend_module_config(module_code)

Check warning on line 101 in backend/geonature/core/command/create_gn_module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/command/create_gn_module.py#L100-L101

Added lines #L100 - L101 were not covered by tests

click.echo("Création de la configuration frontend…")
create_frontend_module_config(module_code)
if build:
click.echo("Rebuild du frontend …")
build_frontend()
click.secho("Rebuild du frontend terminé.", fg="green")

Check warning on line 106 in backend/geonature/core/command/create_gn_module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/core/command/create_gn_module.py#L103-L106

Added lines #L103 - L106 were not covered by tests

if build:
click.echo("Rebuild du frontend …")
build_frontend()
click.secho("Rebuild du frontend terminé.", fg="green")
if upgrade_db:
click.echo("Installation / mise à jour de la base de données…")
if not module_db_upgrade(module_dist, x_arg=x_arg):
Expand Down
2 changes: 1 addition & 1 deletion backend/geonature/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parents(self):
return SequenceMock()

def resolve(self):
return True
return self


def patch_monkeypatch(monkeypatch):
Expand Down
20 changes: 16 additions & 4 deletions backend/geonature/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@

def get_module_config(module_dist):
module_code = module_dist.entry_points["code"].load()
config_schema = module_dist.entry_points["config_schema"].load()
config = {"MODULE_CODE": module_code, "MODULE_URL": f"/{module_code.lower()}"}
config.update(load_and_validate_toml(get_module_config_path(module_code), config_schema))
config = {
"MODULE_CODE": module_code,
"MODULE_URL": f"/{module_code.lower()}", # path to the module in the frontend
"MODULE_API": f"/{module_code.lower()}", # path to the module API
}
try:
config_schema = module_dist.entry_points["config_schema"].load()
except KeyError:
pass # this module does not have any config

Check warning on line 53 in backend/geonature/utils/module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/utils/module.py#L52-L53

Added lines #L52 - L53 were not covered by tests
else:
config.update(load_and_validate_toml(get_module_config_path(module_code), config_schema))
return config


Expand Down Expand Up @@ -102,6 +110,10 @@
).scalar_one_or_none()
if module is None:
# add module to database
try:
module_label = module_dist.entry_points["label"].load()
except KeyError:
module_label = module_code.capitalize()

Check warning on line 116 in backend/geonature/utils/module.py

View check run for this annotation

Codecov / codecov/patch

backend/geonature/utils/module.py#L113-L116

Added lines #L113 - L116 were not covered by tests
try:
module_picto = module_dist.entry_points["picto"].load()
except KeyError:
Expand All @@ -117,7 +129,7 @@
module = TModules(
type=module_type,
module_code=module_code,
module_label=module_code.capitalize(),
module_label=module_label,
module_path=module_code.lower(),
module_target="_self",
module_picto=module_picto,
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

- Amélioration de la recherche libre des métadonnées en cherchant chaque mot indépendamment (#3295, par @jbrieuclp)
- Amélioration de l'affichage de la photo du taxon sur les fiches taxon (#3287, par @edelclaux)
- Améliorations de la commande d’installation des modules (#3261 par @bouttier)

**🐛 Corrections**

- Correction de la pagination quand on filtre les discussions de la page d'accueil sur "Mes discussions" (#3288, par @edelclaux)
- Correction du nombre de taxons sur les fiches des cadres d'acquisition (#3228, par @jacquesfize)


## 2.15.0 - Pavo cristatus 🦚 (2025-12-11)

**⏩ En bref**
Expand Down
Loading