diff --git a/boefjes/tests/integration/test_api.py b/boefjes/tests/integration/test_api.py index 67cd3b95700..59f50b0a61c 100644 --- a/boefjes/tests/integration/test_api.py +++ b/boefjes/tests/integration/test_api.py @@ -151,6 +151,7 @@ def test_update_plugins(test_client, organisation): response = test_client.get(f"/v1/organisations/{organisation.id}/plugins/{boefje.id}") assert response.json()["description"] == "4" + assert response.json()["scan_level"] == 3 assert response.json()["enabled"] is True assert response.json()["scan_level"] == 3 assert response.json()["interval"] == 20 diff --git a/boefjes/tests/integration/test_sql_repositories.py b/boefjes/tests/integration/test_sql_repositories.py index db69569da51..0bd76c21995 100644 --- a/boefjes/tests/integration/test_sql_repositories.py +++ b/boefjes/tests/integration/test_sql_repositories.py @@ -161,9 +161,17 @@ def test_bare_boefje_storage(plugin_storage): boefje.description = "4" boefje.scan_level = 3 + assert storage.boefje_by_id(boefje.id).description == "4" boefje.description = "4" + with plugin_storage as storage: + storage.update_boefje(boefje.id, {"scan_level": 3}) + + assert storage.boefje_by_id(boefje.id).scan_level == 3 + + boefje.description = "4" + boefje.scan_level = 3 all_plugins = storage.get_all() assert all_plugins == [boefje] diff --git a/rocky/katalogus/client.py b/rocky/katalogus/client.py index 846e0739658..9cd9fa62b74 100644 --- a/rocky/katalogus/client.py +++ b/rocky/katalogus/client.py @@ -221,6 +221,18 @@ def create_plugin(self, plugin: Plugin) -> None: else: logger.info("Plugin %s could not be created", plugin.name) + def edit_plugin(self, plugin: Plugin) -> None: + response = self.session.patch( + f"{self.organization_uri}/boefjes/{plugin.id}", + content=plugin.model_dump_json(exclude_none=True), + ) + response.raise_for_status() + + if response.status_code == codes.CREATED: + logger.info("Plugin %s", plugin.name) + else: + logger.info("Plugin %s could not be created", plugin.name) + def parse_boefje(boefje: dict) -> Boefje: scan_level = SCAN_LEVEL(boefje["scan_level"]) diff --git a/rocky/katalogus/templates/boefje_setup.html b/rocky/katalogus/templates/boefje_setup.html index ecf96d52b47..48c2d75c0fe 100644 --- a/rocky/katalogus/templates/boefje_setup.html +++ b/rocky/katalogus/templates/boefje_setup.html @@ -11,6 +11,8 @@
{% if boefje_variant %}

{% translate "Boefje variant setup" %}

+ {% elif edit_boefje_name %} +

{% translate "Edit" %} "{{ edit_boefje_name }}"

{% else %}

{% translate "Boefje setup" %}

{% endif %} @@ -25,8 +27,19 @@

{% translate "Boefje setup" %}

{% include "partials/form/fieldset.html" with legend=fieldset_legend fields=form %}
- - + {% if edit_boefje_name %} + + {% translate "Discard changes" %} + {% elif boefje_variant %} + + {% translate "Discard variant" %} + {% else %} + + {% translate "Discard new Boefje" %} + {% endif %}
diff --git a/rocky/katalogus/templates/plugin_container_image.html b/rocky/katalogus/templates/plugin_container_image.html index b823ef14e3c..17ddba9b025 100644 --- a/rocky/katalogus/templates/plugin_container_image.html +++ b/rocky/katalogus/templates/plugin_container_image.html @@ -1,4 +1,5 @@ {% load static %} +{% load humanize %} {% load i18n %}
@@ -44,6 +45,7 @@

{% translate "Variants" %}

{% translate "Name" %} {% translate "Scan level" %} {% translate "Status" %} + {% translate "Age" %} @@ -70,6 +72,9 @@

{% translate "Variants" %}

{% translate "Disabled" %} {% endif %} + + {{ variant.created|naturaltime }} +