diff --git a/amt/api/ai_act_profile.py b/amt/api/ai_act_profile.py index 967b4ed3..1e5f8132 100644 --- a/amt/api/ai_act_profile.py +++ b/amt/api/ai_act_profile.py @@ -4,14 +4,14 @@ from fastapi import Request -from amt.api.publication_category import PublicationCategories from amt.core.internationalization import get_current_translation class AiActProfileItem(Enum): TYPE = "type" OPEN_SOURCE = "open_source" - PUBLICATION_CATEGORY = "publication_category" + RISK_GROUP = "risk_group" + CONFORMITY_ASSESSMENT_BODY = "conformity_assessment_body" SYSTEMIC_RISK = "systemic_risk" TRANSPARENCY_OBLIGATIONS = "transparency_obligations" ROLE = "role" @@ -24,8 +24,10 @@ def get_translation(item: AiActProfileItem, translations: NullTranslations) -> s return _("Type") case AiActProfileItem.OPEN_SOURCE: return _("Is the application open source?") - case AiActProfileItem.PUBLICATION_CATEGORY: - return _("Publication Category") + case AiActProfileItem.RISK_GROUP: + return _("In what risk group falls the application?") + case AiActProfileItem.CONFORMITY_ASSESSMENT_BODY: + return _("Does a conformity assessment need to be performed by an accredited body") case AiActProfileItem.SYSTEMIC_RISK: return _("Is there a systemic risk?") case AiActProfileItem.TRANSPARENCY_OBLIGATIONS: @@ -54,14 +56,17 @@ class AiActProfileSelector: radio_select: list[SelectAiProfileItem] | None multiple_select: list[SelectAiProfileItem] | None binary_select: list[SelectAiProfileItem] | None + dropdown_select: list[SelectAiProfileItem] | None def __init__( self, radio_select: list[SelectAiProfileItem] | None = None, multiple_select: list[SelectAiProfileItem] | None = None, + dropdown_select: list[SelectAiProfileItem] | None = None, binary_select: list[SelectAiProfileItem] | None = None, ) -> None: self.radio_select = radio_select + self.dropdown_select = dropdown_select self.multiple_select = multiple_select self.binary_select = binary_select @@ -71,32 +76,55 @@ def get_ai_act_profile_selector(request: Request) -> AiActProfileSelector: "AI-systeem", "AI-systeem voor algemene doeleinden", "AI-model voor algemene doeleinden", + "impactvol algoritme", + "niet-impactvol algoritme", + "geen algoritme", ) - role_options = ("aanbieder", "gebruiksverantwoordelijke") - publication_category_options = (*(p.value for p in PublicationCategories), "niet van toepassing") + + role_options = ( + "aanbieder", + "gebruiksverantwoordelijke", + "aanbieder & gebruiksverantwoordelijke", + "importeur", + "distributeur", + ) + + risk_group_options = ( + "hoog-risico AI", + "geen hoog-risico AI", + "verboden AI", + "uitzondering van toepassing", + "niet van toepassing", + ) + + conformity_assessment_body_options = ("beoordeling door derde partij", "niet van toepassing") + systemic_risk_options = ("systeemrisico", "geen systeemrisico", "niet van toepassing") transparency_obligations_options = ( "transparantieverplichtingen", "geen transparantieverplichtingen", "niet van toepassing", ) - open_source_options = ("open-source", "geen open-source") + open_source_options = ("open-source", "geen open-source", "niet van toepassing") translations = get_current_translation(request) return AiActProfileSelector( - radio_select=[ + multiple_select=[ + SelectAiProfileItem(AiActProfileItem.ROLE, role_options, translations), + ], + dropdown_select=[ SelectAiProfileItem(AiActProfileItem.TYPE, type_options, translations), - SelectAiProfileItem(AiActProfileItem.PUBLICATION_CATEGORY, publication_category_options, translations), + SelectAiProfileItem(AiActProfileItem.RISK_GROUP, risk_group_options, translations), SelectAiProfileItem( AiActProfileItem.TRANSPARENCY_OBLIGATIONS, transparency_obligations_options, translations ), SelectAiProfileItem(AiActProfileItem.SYSTEMIC_RISK, systemic_risk_options, translations), - ], - multiple_select=[ - SelectAiProfileItem(AiActProfileItem.ROLE, role_options, translations), - ], - binary_select=[ SelectAiProfileItem(AiActProfileItem.OPEN_SOURCE, open_source_options, translations), + SelectAiProfileItem( + AiActProfileItem.CONFORMITY_ASSESSMENT_BODY, conformity_assessment_body_options, translations + ), ], + radio_select=[], + binary_select=[], ) diff --git a/amt/api/publication_category.py b/amt/api/publication_category.py deleted file mode 100644 index 4847358c..00000000 --- a/amt/api/publication_category.py +++ /dev/null @@ -1,38 +0,0 @@ -from collections.abc import Callable - -from fastapi import Request - -from ..schema.localized_value_item import LocalizedValueItem -from .localizable import LocalizableEnum, get_localized_enum, get_localized_enums - - -class PublicationCategories(LocalizableEnum): - IMPACTVOL_ALGORITME = "impactvol algoritme" - NIET_IMPACTVOL_ALGORITME = "niet-impactvol algoritme" - HOOG_RISICO_AI = "hoog-risico AI" - GEEN_HOOG_RISICO_AI = "geen hoog-risico AI" - VERBODEN_AI = "verboden AI" - UITZONDERING_VAN_TOEPASSING = "uitzondering van toepassing" - - @classmethod - def get_display_values( - cls: type["PublicationCategories"], _: Callable[[str], str] - ) -> dict["PublicationCategories", str]: - return { - cls.IMPACTVOL_ALGORITME: _("Impactful algorithm"), - cls.NIET_IMPACTVOL_ALGORITME: _("Non-impactful algorithm"), - cls.HOOG_RISICO_AI: _("High-risk AI"), - cls.GEEN_HOOG_RISICO_AI: _("No high-risk AI"), - cls.VERBODEN_AI: _("Forbidden AI"), - cls.UITZONDERING_VAN_TOEPASSING: _("Exception of application"), - } - - -def get_localized_publication_category( - key: PublicationCategories | None, request: Request -) -> LocalizedValueItem | None: - return get_localized_enum(key, request) - - -def get_localized_publication_categories(request: Request) -> list[LocalizedValueItem | None]: - return get_localized_enums(PublicationCategories, request) diff --git a/amt/api/risk_group.py b/amt/api/risk_group.py new file mode 100644 index 00000000..b248f26a --- /dev/null +++ b/amt/api/risk_group.py @@ -0,0 +1,32 @@ +from collections.abc import Callable + +from fastapi import Request + +from ..schema.localized_value_item import LocalizedValueItem +from .localizable import LocalizableEnum, get_localized_enum, get_localized_enums + + +class RiskGroup(LocalizableEnum): + HOOG_RISICO_AI = "hoog-risico AI" + GEEN_HOOG_RISICO_AI = "geen hoog-risico AI" + VERBODEN_AI = "verboden AI" + UITZONDERING_VAN_TOEPASSING = "uitzondering van toepassing" + NIET_VAN_TOEPASSING = "niet van toepassing" + + @classmethod + def get_display_values(cls: type["RiskGroup"], _: Callable[[str], str]) -> dict["RiskGroup", str]: + return { + cls.HOOG_RISICO_AI: _("hoog-risico AI"), + cls.GEEN_HOOG_RISICO_AI: _("geen hoog-risico AI"), + cls.VERBODEN_AI: _("verboden AI"), + cls.UITZONDERING_VAN_TOEPASSING: _("uitzondering van toepassing"), + cls.NIET_VAN_TOEPASSING: _("niet van toepassing"), + } + + +def get_localized_risk_group(key: RiskGroup | None, request: Request) -> LocalizedValueItem | None: + return get_localized_enum(key, request) + + +def get_localized_risk_groups(request: Request) -> list[LocalizedValueItem | None]: + return get_localized_enums(RiskGroup, request) diff --git a/amt/api/routes/algorithms.py b/amt/api/routes/algorithms.py index 1bd20f3b..3af0ee99 100644 --- a/amt/api/routes/algorithms.py +++ b/amt/api/routes/algorithms.py @@ -10,8 +10,8 @@ from amt.api.group_by_category import get_localized_group_by_categories from amt.api.lifecycles import Lifecycles, get_localized_lifecycle, get_localized_lifecycles from amt.api.navigation import Navigation, resolve_base_navigation_items, resolve_navigation_items -from amt.api.publication_category import ( - get_localized_publication_categories, +from amt.api.risk_group import ( + get_localized_risk_groups, ) from amt.api.routes.shared import get_filters_and_sort_by from amt.core.authorization import get_user @@ -81,7 +81,7 @@ async def get_root( "start": skip, "search": search, "lifecycles": get_localized_lifecycles(request), - "publication_categories": get_localized_publication_categories(request), + "risk_groups": get_localized_risk_groups(request), "group_by_categories": get_localized_group_by_categories(request), "filters": localized_filters, "sort_by": sort_by, @@ -105,6 +105,8 @@ async def get_new( sub_menu_items = resolve_navigation_items([Navigation.ALGORITHMS_OVERVIEW], request) # pyright: ignore [reportUnusedVariable] # noqa breadcrumbs = resolve_base_navigation_items([Navigation.ALGORITHMS_ROOT, Navigation.ALGORITHM_NEW], request) + # clean up session storage + ai_act_profile = get_ai_act_profile_selector(request) user = get_user(request) diff --git a/amt/api/routes/shared.py b/amt/api/routes/shared.py index bc8c378a..c53b2420 100644 --- a/amt/api/routes/shared.py +++ b/amt/api/routes/shared.py @@ -2,7 +2,7 @@ from amt.api.lifecycles import Lifecycles, get_localized_lifecycle from amt.api.organization_filter_options import OrganizationFilterOptions, get_localized_organization_filter -from amt.api.publication_category import PublicationCategories, get_localized_publication_category +from amt.api.risk_group import RiskGroup, get_localized_risk_group from amt.schema.localized_value_item import LocalizedValueItem @@ -37,8 +37,8 @@ def get_localized_value(key: str, value: str, request: Request) -> LocalizedValu match key: case "lifecycle": localized = get_localized_lifecycle(Lifecycles(value), request) - case "publication-category": - localized = get_localized_publication_category(PublicationCategories[value], request) + case "risk-group": + localized = get_localized_risk_group(RiskGroup[value], request) case "organization-type": localized = get_localized_organization_filter(OrganizationFilterOptions(value), request) case _: diff --git a/amt/locale/base.pot b/amt/locale/base.pot index 0c0fa0e6..63ed74ae 100644 --- a/amt/locale/base.pot +++ b/amt/locale/base.pot @@ -26,18 +26,22 @@ msgid "Is the application open source?" msgstr "" #: amt/api/ai_act_profile.py:28 -msgid "Publication Category" +msgid "In what risk group falls the application?" msgstr "" #: amt/api/ai_act_profile.py:30 -msgid "Is there a systemic risk?" +msgid "Does a conformity assessment need to be performed by an accredited body" msgstr "" #: amt/api/ai_act_profile.py:32 -msgid "Is there a transparency obligation?" +msgid "Is there a systemic risk?" msgstr "" #: amt/api/ai_act_profile.py:34 +msgid "Is there a transparency obligation?" +msgstr "" + +#: amt/api/ai_act_profile.py:36 msgid "Role" msgstr "" @@ -142,7 +146,7 @@ msgstr "" msgid "Model" msgstr "" -#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:151 +#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:170 msgid "Instruments" msgstr "" @@ -165,28 +169,24 @@ msgstr "" msgid "My organizations" msgstr "" -#: amt/api/publication_category.py:22 -msgid "Impactful algorithm" +#: amt/api/risk_group.py:19 +msgid "hoog-risico AI" msgstr "" -#: amt/api/publication_category.py:23 -msgid "Non-impactful algorithm" +#: amt/api/risk_group.py:20 +msgid "geen hoog-risico AI" msgstr "" -#: amt/api/publication_category.py:24 -msgid "High-risk AI" +#: amt/api/risk_group.py:21 +msgid "verboden AI" msgstr "" -#: amt/api/publication_category.py:25 -msgid "No high-risk AI" +#: amt/api/risk_group.py:22 +msgid "uitzondering van toepassing" msgstr "" -#: amt/api/publication_category.py:26 -msgid "Forbidden AI" -msgstr "" - -#: amt/api/publication_category.py:27 -msgid "Exception of application" +#: amt/api/risk_group.py:23 +msgid "niet van toepassing" msgstr "" #: amt/api/forms/algorithm.py:19 @@ -312,13 +312,13 @@ msgid "" msgstr "" #: amt/site/templates/algorithms/details_base.html.j2:39 -#: amt/site/templates/algorithms/new.html.j2:134 +#: amt/site/templates/algorithms/new.html.j2:153 #: amt/site/templates/organizations/members.html.j2:33 msgid "Yes" msgstr "" #: amt/site/templates/algorithms/details_base.html.j2:44 -#: amt/site/templates/algorithms/new.html.j2:144 +#: amt/site/templates/algorithms/new.html.j2:163 #: amt/site/templates/organizations/members.html.j2:36 msgid "No" msgstr "" @@ -548,21 +548,25 @@ msgstr "" msgid "Find your AI Act profile" msgstr "" -#: amt/site/templates/algorithms/new.html.j2:153 +#: amt/site/templates/algorithms/new.html.j2:112 +msgid "Select Option" +msgstr "" + +#: amt/site/templates/algorithms/new.html.j2:172 msgid "" "Overview of instruments for the responsible development, deployment, " "assessment and monitoring of algorithms and AI-systems." msgstr "" -#: amt/site/templates/algorithms/new.html.j2:161 +#: amt/site/templates/algorithms/new.html.j2:180 msgid "Choose one or more instruments" msgstr "" -#: amt/site/templates/algorithms/new.html.j2:185 +#: amt/site/templates/algorithms/new.html.j2:204 msgid "Create Algorithm" msgstr "" -#: amt/site/templates/algorithms/new.html.j2:202 +#: amt/site/templates/algorithms/new.html.j2:221 msgid "Copy results and close" msgstr "" @@ -852,14 +856,14 @@ msgid "Category" msgstr "" #: amt/site/templates/parts/algorithm_search.html.j2:66 -msgid "Select publication category" +msgid "Select risk group" msgstr "" -#: amt/site/templates/parts/algorithm_search.html.j2:84 +#: amt/site/templates/parts/algorithm_search.html.j2:82 msgid "Group by" msgstr "" -#: amt/site/templates/parts/algorithm_search.html.j2:94 +#: amt/site/templates/parts/algorithm_search.html.j2:92 msgid "Select group by" msgstr "" diff --git a/amt/locale/en_US/LC_MESSAGES/messages.mo b/amt/locale/en_US/LC_MESSAGES/messages.mo index 83f4ad01..738f59d7 100644 Binary files a/amt/locale/en_US/LC_MESSAGES/messages.mo and b/amt/locale/en_US/LC_MESSAGES/messages.mo differ diff --git a/amt/locale/en_US/LC_MESSAGES/messages.po b/amt/locale/en_US/LC_MESSAGES/messages.po index 38587da6..288912d0 100644 --- a/amt/locale/en_US/LC_MESSAGES/messages.po +++ b/amt/locale/en_US/LC_MESSAGES/messages.po @@ -27,18 +27,22 @@ msgid "Is the application open source?" msgstr "" #: amt/api/ai_act_profile.py:28 -msgid "Publication Category" +msgid "In what risk group falls the application?" msgstr "" #: amt/api/ai_act_profile.py:30 -msgid "Is there a systemic risk?" +msgid "Does a conformity assessment need to be performed by an accredited body" msgstr "" #: amt/api/ai_act_profile.py:32 -msgid "Is there a transparency obligation?" +msgid "Is there a systemic risk?" msgstr "" #: amt/api/ai_act_profile.py:34 +msgid "Is there a transparency obligation?" +msgstr "" + +#: amt/api/ai_act_profile.py:36 msgid "Role" msgstr "" @@ -143,7 +147,7 @@ msgstr "" msgid "Model" msgstr "" -#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:151 +#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:170 msgid "Instruments" msgstr "" @@ -166,29 +170,25 @@ msgstr "" msgid "My organizations" msgstr "" -#: amt/api/publication_category.py:22 -msgid "Impactful algorithm" -msgstr "" +#: amt/api/risk_group.py:19 +msgid "hoog-risico AI" +msgstr "high-risk AI" -#: amt/api/publication_category.py:23 -msgid "Non-impactful algorithm" -msgstr "" +#: amt/api/risk_group.py:20 +msgid "geen hoog-risico AI" +msgstr "No high-risk AI" -#: amt/api/publication_category.py:24 -msgid "High-risk AI" -msgstr "" +#: amt/api/risk_group.py:21 +msgid "verboden AI" +msgstr "Forbidden A" -#: amt/api/publication_category.py:25 -msgid "No high-risk AI" -msgstr "" - -#: amt/api/publication_category.py:26 -msgid "Forbidden AI" -msgstr "" +#: amt/api/risk_group.py:22 +msgid "uitzondering van toepassing" +msgstr "Exception of application" -#: amt/api/publication_category.py:27 -msgid "Exception of application" -msgstr "" +#: amt/api/risk_group.py:23 +msgid "niet van toepassing" +msgstr "Not applicable" #: amt/api/forms/algorithm.py:19 msgid "Select organization" @@ -313,13 +313,13 @@ msgid "" msgstr "" #: amt/site/templates/algorithms/details_base.html.j2:39 -#: amt/site/templates/algorithms/new.html.j2:134 +#: amt/site/templates/algorithms/new.html.j2:153 #: amt/site/templates/organizations/members.html.j2:33 msgid "Yes" msgstr "" #: amt/site/templates/algorithms/details_base.html.j2:44 -#: amt/site/templates/algorithms/new.html.j2:144 +#: amt/site/templates/algorithms/new.html.j2:163 #: amt/site/templates/organizations/members.html.j2:36 msgid "No" msgstr "" @@ -549,21 +549,25 @@ msgstr "" msgid "Find your AI Act profile" msgstr "" -#: amt/site/templates/algorithms/new.html.j2:153 +#: amt/site/templates/algorithms/new.html.j2:112 +msgid "Select Option" +msgstr "" + +#: amt/site/templates/algorithms/new.html.j2:172 msgid "" "Overview of instruments for the responsible development, deployment, " "assessment and monitoring of algorithms and AI-systems." msgstr "" -#: amt/site/templates/algorithms/new.html.j2:161 +#: amt/site/templates/algorithms/new.html.j2:180 msgid "Choose one or more instruments" msgstr "" -#: amt/site/templates/algorithms/new.html.j2:185 +#: amt/site/templates/algorithms/new.html.j2:204 msgid "Create Algorithm" msgstr "" -#: amt/site/templates/algorithms/new.html.j2:202 +#: amt/site/templates/algorithms/new.html.j2:221 msgid "Copy results and close" msgstr "" @@ -853,14 +857,14 @@ msgid "Category" msgstr "" #: amt/site/templates/parts/algorithm_search.html.j2:66 -msgid "Select publication category" +msgid "Select risk group" msgstr "" -#: amt/site/templates/parts/algorithm_search.html.j2:84 +#: amt/site/templates/parts/algorithm_search.html.j2:82 msgid "Group by" msgstr "" -#: amt/site/templates/parts/algorithm_search.html.j2:94 +#: amt/site/templates/parts/algorithm_search.html.j2:92 msgid "Select group by" msgstr "" diff --git a/amt/locale/nl_NL/LC_MESSAGES/messages.mo b/amt/locale/nl_NL/LC_MESSAGES/messages.mo index f86357c1..b82af76b 100644 Binary files a/amt/locale/nl_NL/LC_MESSAGES/messages.mo and b/amt/locale/nl_NL/LC_MESSAGES/messages.mo differ diff --git a/amt/locale/nl_NL/LC_MESSAGES/messages.po b/amt/locale/nl_NL/LC_MESSAGES/messages.po index 35fe9b80..e1c86fab 100644 --- a/amt/locale/nl_NL/LC_MESSAGES/messages.po +++ b/amt/locale/nl_NL/LC_MESSAGES/messages.po @@ -27,18 +27,24 @@ msgid "Is the application open source?" msgstr "Is de applicatie open source?" #: amt/api/ai_act_profile.py:28 -msgid "Publication Category" -msgstr "Publicatiecategorie" +msgid "In what risk group falls the application?" +msgstr "In welke risicogroep valt de applicatie?" #: amt/api/ai_act_profile.py:30 +msgid "Does a conformity assessment need to be performed by an accredited body" +msgstr "" +"Moet een conformiteitsbeoordeling worden uitgevoerd door een " +"geaccrediteerde instantie?" + +#: amt/api/ai_act_profile.py:32 msgid "Is there a systemic risk?" msgstr "Is er sprake van systematisch risico?" -#: amt/api/ai_act_profile.py:32 +#: amt/api/ai_act_profile.py:34 msgid "Is there a transparency obligation?" msgstr "Zijn er transparantieverplichtingen?" -#: amt/api/ai_act_profile.py:34 +#: amt/api/ai_act_profile.py:36 msgid "Role" msgstr "Rol" @@ -143,7 +149,7 @@ msgstr "Data" msgid "Model" msgstr "Model" -#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:151 +#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:170 msgid "Instruments" msgstr "Instrumenten" @@ -166,30 +172,26 @@ msgstr "Alle organisaties" msgid "My organizations" msgstr "Mijn organisaties" -#: amt/api/publication_category.py:22 -msgid "Impactful algorithm" -msgstr "Impactvol algoritme" - -#: amt/api/publication_category.py:23 -msgid "Non-impactful algorithm" -msgstr "Niet-impactvol algoritme" - -#: amt/api/publication_category.py:24 -msgid "High-risk AI" +#: amt/api/risk_group.py:19 +msgid "hoog-risico AI" msgstr "Hoog-risico AI" -#: amt/api/publication_category.py:25 -msgid "No high-risk AI" +#: amt/api/risk_group.py:20 +msgid "geen hoog-risico AI" msgstr "Geen hoog-risico AI" -#: amt/api/publication_category.py:26 -msgid "Forbidden AI" +#: amt/api/risk_group.py:21 +msgid "verboden AI" msgstr "Verboden AI" -#: amt/api/publication_category.py:27 -msgid "Exception of application" +#: amt/api/risk_group.py:22 +msgid "uitzondering van toepassing" msgstr "Uitzondering van toepassing" +#: amt/api/risk_group.py:23 +msgid "niet van toepassing" +msgstr "Niet van toepassing" + #: amt/api/forms/algorithm.py:19 msgid "Select organization" msgstr "Selecteer organisatie" @@ -325,13 +327,13 @@ msgstr "" " verwijderd." #: amt/site/templates/algorithms/details_base.html.j2:39 -#: amt/site/templates/algorithms/new.html.j2:134 +#: amt/site/templates/algorithms/new.html.j2:153 #: amt/site/templates/organizations/members.html.j2:33 msgid "Yes" msgstr "Ja" #: amt/site/templates/algorithms/details_base.html.j2:44 -#: amt/site/templates/algorithms/new.html.j2:144 +#: amt/site/templates/algorithms/new.html.j2:163 #: amt/site/templates/organizations/members.html.j2:36 msgid "No" msgstr "Nee" @@ -566,7 +568,11 @@ msgstr "" msgid "Find your AI Act profile" msgstr "Vind uw AI Act profiel" -#: amt/site/templates/algorithms/new.html.j2:153 +#: amt/site/templates/algorithms/new.html.j2:112 +msgid "Select Option" +msgstr "Selecteer organisatie" + +#: amt/site/templates/algorithms/new.html.j2:172 msgid "" "Overview of instruments for the responsible development, deployment, " "assessment and monitoring of algorithms and AI-systems." @@ -574,15 +580,15 @@ msgstr "" "Overzicht van aanbevolen instrument voor het verantwoord ontwikkelen, " "gebruiken, beoordelen en monitoren van algoritmes en AI-systemen." -#: amt/site/templates/algorithms/new.html.j2:161 +#: amt/site/templates/algorithms/new.html.j2:180 msgid "Choose one or more instruments" msgstr "Kies één of meerdere instrumenten" -#: amt/site/templates/algorithms/new.html.j2:185 +#: amt/site/templates/algorithms/new.html.j2:204 msgid "Create Algorithm" msgstr "Creëer algoritme" -#: amt/site/templates/algorithms/new.html.j2:202 +#: amt/site/templates/algorithms/new.html.j2:221 msgid "Copy results and close" msgstr "Resultaten overnemen en sluiten" @@ -879,14 +885,14 @@ msgid "Category" msgstr "Categorie" #: amt/site/templates/parts/algorithm_search.html.j2:66 -msgid "Select publication category" -msgstr "Selecteer publicatiecategorie" +msgid "Select risk group" +msgstr "Selecteer groepering" -#: amt/site/templates/parts/algorithm_search.html.j2:84 +#: amt/site/templates/parts/algorithm_search.html.j2:82 msgid "Group by" msgstr "Groeperen op" -#: amt/site/templates/parts/algorithm_search.html.j2:94 +#: amt/site/templates/parts/algorithm_search.html.j2:92 msgid "Select group by" msgstr "Selecteer groepering" diff --git a/amt/repositories/algorithms.py b/amt/repositories/algorithms.py index 8f647348..c7e3a48c 100644 --- a/amt/repositories/algorithms.py +++ b/amt/repositories/algorithms.py @@ -8,7 +8,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy_utils import escape_like # pyright: ignore[reportMissingTypeStubs, reportUnknownVariableType] -from amt.api.publication_category import PublicationCategories +from amt.api.risk_group import RiskGroup from amt.core.exceptions import AMTRepositoryError from amt.models import Algorithm from amt.repositories.deps import get_session @@ -85,10 +85,10 @@ async def paginate( # noqa match key: case "lifecycle": statement = statement.filter(Algorithm.lifecycle == value) - case "publication-category": + case "risk-group": statement = statement.filter( - Algorithm.system_card_json["ai_act_profile"]["publication_category"].as_string() - == PublicationCategories[value].value + Algorithm.system_card_json["ai_act_profile"]["risk_group"].as_string() + == RiskGroup[value].value ) case _: raise TypeError(f"Unknown filter type with key: {key}") # noqa diff --git a/amt/schema/ai_act_profile.py b/amt/schema/ai_act_profile.py index d42a332f..7a4a3563 100644 --- a/amt/schema/ai_act_profile.py +++ b/amt/schema/ai_act_profile.py @@ -6,7 +6,8 @@ class AiActProfile(BaseModel): type: str | None = Field(default=None) open_source: str | None = Field(default=None) - publication_category: str | None = Field(default=None) + risk_group: str | None = Field(default=None) + conformity_assessment_body: str | None = Field(default=None) systemic_risk: str | None = Field(default=None) transparency_obligations: str | None = Field(default=None) role: list[str] | str | None = Field(default=None) diff --git a/amt/schema/algorithm.py b/amt/schema/algorithm.py index de4ac26b..f7301fa0 100644 --- a/amt/schema/algorithm.py +++ b/amt/schema/algorithm.py @@ -11,7 +11,8 @@ class AlgorithmNew(AlgorithmBase): instruments: list[str] | str = [] type: str = Field(default=None) open_source: str = Field(default=None) - publication_category: str = Field(default=None) + risk_group: str = Field(default=None) + conformity_assessment_body: str = Field(default=None) systemic_risk: str = Field(default=None) transparency_obligations: str = Field(default=None) role: list[str] | str = [] diff --git a/amt/schema/publication_category.py b/amt/schema/publication_category.py deleted file mode 100644 index 3ce7c08e..00000000 --- a/amt/schema/publication_category.py +++ /dev/null @@ -1,6 +0,0 @@ -from pydantic import BaseModel - - -class PublicationCategory(BaseModel): - id: str - name: str diff --git a/amt/services/algorithms.py b/amt/services/algorithms.py index 6dbb107f..e3408eab 100644 --- a/amt/services/algorithms.py +++ b/amt/services/algorithms.py @@ -65,7 +65,8 @@ async def create(self, algorithm_new: AlgorithmNew, user_id: UUID | str) -> Algo ai_act_profile = AiActProfile( type=algorithm_new.type, open_source=algorithm_new.open_source, - publication_category=algorithm_new.publication_category, + risk_group=algorithm_new.risk_group, + conformity_assessment_body=algorithm_new.conformity_assessment_body, systemic_risk=algorithm_new.systemic_risk, transparency_obligations=algorithm_new.transparency_obligations, role=algorithm_new.role, diff --git a/amt/services/task_registry.py b/amt/services/task_registry.py index da1b8b16..83489d39 100644 --- a/amt/services/task_registry.py +++ b/amt/services/task_registry.py @@ -81,6 +81,6 @@ def _parse_attribute_values(attr: str, ai_act_profile: AiActProfile) -> set[str] if attr == "role": return {s.strip() for s in getattr(ai_act_profile, attr, "").split("+")} if attr == "risk_category": - return {getattr(ai_act_profile, "publication_category", "")} + return {getattr(ai_act_profile, "risk_group", "")} return {getattr(ai_act_profile, attr, "")} diff --git a/amt/site/static/ts/amt.ts b/amt/site/static/ts/amt.ts index 267a6fe6..47d93a26 100644 --- a/amt/site/static/ts/amt.ts +++ b/amt/site/static/ts/amt.ts @@ -8,10 +8,29 @@ import "../scss/layout.scss"; _hyperscript.browserInit(); +const keysToRemove = [ + "labelsbysubcategory", + "answers", + "categoryState", + "categoryTrace", + "currentCategory", + "currentconclusion", + "currentquestion", + "currentSubCategory", + "labels", + "previousCategory", + "previousSubCategory", + "subCategoryTrace", +]; +if (window.location.pathname === "/algorithms/new") { + keysToRemove.forEach((key) => { + sessionStorage.removeItem(key); + }); +} + document.addEventListener("DOMContentLoaded", function () { // TODO (robbert): we need (better) event handling and displaying of server errors document.body.addEventListener("htmx:sendError", function () { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion document.getElementById("errorContainer")!.innerHTML = "