Skip to content

Commit

Permalink
Resolved some PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JanhSander committed Mar 8, 2024
1 parent 0fc24c0 commit 3cb49df
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/datadoc/backend/code_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CodeListItem:
"""Data structure for a code list item."""

titles: dict[str, str]
unit_code: str
code: str

def get_title(self, language: SupportedLanguages) -> str:
"""Get the title in the given language."""
Expand Down Expand Up @@ -107,7 +107,7 @@ def _extract_titles(
list_of_titles.append(titles)
return list_of_titles

def _create_unit_types_from_dataframe(
def _create_code_list_from_dataframe(
self,
classifications_dataframes: dict[SupportedLanguages, pd.DataFrame],
) -> list[CodeListItem]:
Expand All @@ -134,7 +134,7 @@ def _get_classification_dataframe_if_loaded(self) -> bool:
if not self._classifications:
self.classifications_dataframes = self.retrieve_external_data()
if self.classifications_dataframes is not None:
self._classifications = self._create_unit_types_from_dataframe(
self._classifications = self._create_code_list_from_dataframe(
self.classifications_dataframes,
)
logger.debug(
Expand Down
6 changes: 3 additions & 3 deletions src/datadoc/frontend/fields/display_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_unit_type_options(
return [
{
"label": unit_type.get_title(language),
"value": unit_type.unit_code,
"value": unit_type.code,
}
for unit_type in state.unit_types.classifications
]
Expand All @@ -72,8 +72,8 @@ def get_owner_options(
"""Collect the owner options for the given language."""
return [
{
"label": f"{option.unit_code} - {option.get_title(language)}",
"value": option.unit_code,
"label": f"{option.code} - {option.get_title(language)}",
"value": option.code,
}
for option in state.organisational_units.classifications
]
Expand Down
18 changes: 9 additions & 9 deletions tests/backend/test_code_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@
"nn": "Adresse",
"en": "Adresse",
},
unit_code="01",
code="01",
),
CodeListItem(
titles={
"nb": "Arbeidsulykke",
"nn": "Arbeidsulykke",
"en": "Arbeidsulykke",
},
unit_code="02",
code="02",
),
CodeListItem(
titles={
"nb": "Bolig",
"nn": "Bolig",
"en": "Bolig",
},
unit_code="03",
code="03",
),
],
),
Expand All @@ -63,23 +63,23 @@
"nn": None,
"en": None,
},
unit_code="01",
code="01",
),
CodeListItem(
titles={
"nb": "Arbeidsulykke",
"nn": None,
"en": None,
},
unit_code="02",
code="02",
),
CodeListItem(
titles={
"nb": "Bolig",
"nn": None,
"en": None,
},
unit_code="03",
code="03",
),
],
),
Expand All @@ -94,23 +94,23 @@
"nn": "Adresse",
"en": "Adresse",
},
unit_code=None,
code=None,
),
CodeListItem(
titles={
"nb": "Arbeidsulykke",
"nn": "Arbeidsulykke",
"en": "Arbeidsulykke",
},
unit_code=None,
code=None,
),
CodeListItem(
titles={
"nb": "Bolig",
"nn": "Bolig",
"en": "Bolig",
},
unit_code=None,
code=None,
),
],
),
Expand Down
5 changes: 5 additions & 0 deletions tests/frontend/callbacks/test_dataset_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def file_path():
"2f72477a-f051-43ee-bf8b-0d8f47b5e0a7",
UUID("2f72477a-f051-43ee-bf8b-0d8f47b5e0a7"),
),
(
DatasetIdentifiers.OWNER,
"Seksjon for dataplattform",
"Seksjon for dataplattform",
),
],
)
def test_accept_dataset_metadata_input_valid_data(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
"nb": "Norge"
},
"id": "2f72477a-f051-43ee-bf8b-0d8f47b5e0a7",
"owner": "NNN",
"owner": {
"en": "",
"nn": "",
"nb": "Seksjon NNN"
},
"file_path": null,
"metadata_created_date": "2022-10-07T07:35:01Z",
"metadata_created_by": "[email protected]",
Expand Down

0 comments on commit 3cb49df

Please sign in to comment.