Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 29, 2024
1 parent 78b1038 commit 9b9e0f2
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 33 deletions.
33 changes: 16 additions & 17 deletions backend/src/openarchiefbeheer/destruction/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from django.utils.translation import gettext, gettext_lazy as _

import xlsxwriter
from furl import furl
from privates.fields import PrivateMediaFileField
from slugify import slugify
from timeline_logger.models import TimelineLog
Expand Down Expand Up @@ -221,15 +222,14 @@ def abort_destruction(self) -> None:

def _make_deleted_zaken_sheet(self, workbook: xlsxwriter.Workbook) -> None:
column_names = [
"url",
"einddatum",
"resultaat",
"startdatum",
"omschrijving",
"identificatie",
"zaaktype url",
"zaaktype omschrijving",
"selectielijst procestype nummer",
"Zaaktype UUID",
"Zaaktype Omschrijving",
"Zaaktype Identificatie",
"Zaak Identificatie",
"Zaak Startdatum",
"Zaak Einddatum",
"Selectielijst Procestype",
"Resultaat",
]

worksheet = workbook.add_worksheet(name=gettext("Deleted zaken"))
Expand All @@ -241,15 +241,14 @@ def _make_deleted_zaken_sheet(self, workbook: xlsxwriter.Workbook) -> None:
)
):
data = [
item.extra_zaak_data["url"],
item.extra_zaak_data["einddatum"],
item.extra_zaak_data["resultaat"],
item.extra_zaak_data["startdatum"],
item.extra_zaak_data["omschrijving"],
item.extra_zaak_data["identificatie"],
item.extra_zaak_data["zaaktype"]["url"],
furl(item.extra_zaak_data["zaaktype"]["url"]).path.segments[-1],
item.extra_zaak_data["zaaktype"]["omschrijving"],
item.extra_zaak_data["zaaktype"]["selectielijst_procestype"]["nummer"],
item.extra_zaak_data["zaaktype"].get("identificatie", ""),
item.extra_zaak_data.get("identificatie", ""),
item.extra_zaak_data["startdatum"],
item.extra_zaak_data["einddatum"],
item.extra_zaak_data["zaaktype"]["selectielijst_procestype"]["naam"],
item.extra_zaak_data["resultaat"]["_expand"]["resultaattype"]["omschrijving"],
]

worksheet.write_row(row_count + 1, 0, data)
Expand Down
55 changes: 41 additions & 14 deletions backend/src/openarchiefbeheer/destruction/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,21 @@ def test_generate_destruction_report(self):
"identificatie": "ZAAK-01",
"startdatum": "2020-01-01",
"einddatum": "2022-01-01",
"resultaat": "http://zaken.nl/api/v1/resultaten/111-111-111",
"resultaat": {
"url": "http://zaken.nl/api/v1/resultaten/111-111-111",
"_expand": {
"resultaattype": {
"url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111",
"archiefactietermijn": "P1D",
"omschrijving": "Resulttype 0",
},
},
},
"zaaktype": {
"url": "http://catalogi.nl/api/v1/zaaktypen/111-111-111",
"omschrijving": "Tralala zaaktype",
"selectielijst_procestype": {
"nummer": 1,
"naam": "Plannen opstellen",
},
},
},
Expand All @@ -320,12 +329,22 @@ def test_generate_destruction_report(self):
"identificatie": "ZAAK-02",
"startdatum": "2020-01-02",
"einddatum": "2022-01-02",
"resultaat": "http://zaken.nl/api/v1/resultaten/111-111-222",
"resultaat": {
"url": "http://zaken.nl/api/v1/resultaten/111-111-222",
"_expand": {
"resultaattype": {
"url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111",
"archiefactietermijn": "P1D",
"omschrijving": "Resulttype 0",
},
},
},
"zaaktype": {
"url": "http://catalogi.nl/api/v1/zaaktypen/111-111-111",
"omschrijving": "Tralala zaaktype",
"selectielijst_procestype": {
"nummer": 1,
"naam": "Beleid en regelgeving opstellen",
},
},
},
Expand All @@ -339,12 +358,21 @@ def test_generate_destruction_report(self):
"identificatie": "ZAAK-03",
"startdatum": "2020-01-03",
"einddatum": "2022-01-03",
"resultaat": "http://zaken.nl/api/v1/resultaten/111-111-333",
"resultaat": {
"url": "http://zaken.nl/api/v1/resultaten/111-111-333",
"_expand": {
"resultaattype": {
"url": "http://catalogue-api.nl/catalogi/api/v1/resultaattypen/111-111-111",
"archiefactietermijn": "P1D",
"omschrijving": "Resulttype 0",
}
},
},
"zaaktype": {
"url": "http://catalogi.nl/api/v1/zaaktypen/111-111-222",
"omschrijving": "Tralala zaaktype",
"selectielijst_procestype": {
"nummer": 2,
"naam": "Instellen en inrichten organisatie",
},
},
},
Expand All @@ -362,15 +390,14 @@ def test_generate_destruction_report(self):
self.assertEqual(
rows[0],
(
"url",
"einddatum",
"resultaat",
"startdatum",
"omschrijving",
"identificatie",
"zaaktype url",
"zaaktype omschrijving",
"selectielijst procestype nummer",
"Zaaktype UUID",
"Zaaktype Omschrijving",
"Zaaktype Identificatie",
"Zaak Identificatie",
"Zaak Startdatum",
"Zaak Einddatum",
"Selectielijst Procestype",
"Resultaat",
),
)
self.assertEqual(
Expand Down
14 changes: 12 additions & 2 deletions backend/src/openarchiefbeheer/zaken/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class SelectielijstklasseChoicesQueryParamSerializer(serializers.Serializer):

class ZaakMetadataSerializer(serializers.ModelSerializer):
zaaktype = serializers.SerializerMethodField()
resultaat = serializers.SerializerMethodField()

class Meta:
model = Zaak
Expand All @@ -97,7 +98,16 @@ def get_zaaktype(self, zaak: Zaak) -> dict | None:
return {
"url": zaaktype["url"],
"omschrijving": zaaktype["omschrijving"],
"selectielijst_procestype": {
"nummer": zaaktype["selectielijst_procestype"]["nummer"]
"identificatie": zaaktype.get("identificatie", ""),
"selectielijst_procestype": zaaktype["selectielijst_procestype"],
}

@extend_schema_field(serializers.JSONField)
def get_resultaat(self, zaak: Zaak) -> dict | None:
resultaattype = zaak._expand["resultaat"]["_expand"]["resultaattype"]
return {
"url": zaak._expand["resultaat"]["url"],
"resultaattype": {
"omschrijving": resultaattype["omschrijving"],
},
}
1 change: 1 addition & 0 deletions backend/src/openarchiefbeheer/zaken/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def post(obj, create, extracted, **kwargs):
"selectielijst_procestype": {
"nummer": 1,
"url": "https://selectielijst.nl/api/v1/procestypen/7ff2b005-4d84-47fe-983a-732bfa958ff5",
"naam": "Evaluatie uitvoeren",
},
"omschrijving": "Aangifte behandelen",
"identificatie": "ZAAKTYPE-01",
Expand Down

0 comments on commit 9b9e0f2

Please sign in to comment.