-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ [#1838] Store zaaktype URL on ZaakTypeConfig
task: https://taiga.maykinmedia.nl/project/open-inwoner/task/1838 this is necessary to avoid performance issues when implementing personalization of categories based on zaaktypen
- Loading branch information
Showing
7 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/open_inwoner/openzaak/migrations/0031_zaaktypeconfig_url.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.20 on 2023-11-14 11:21 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("openzaak", "0030_merge_20231113_1518"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="zaaktypeconfig", | ||
name="url", | ||
field=models.URLField(blank=True, verbose_name="Zaaktype URL"), | ||
), | ||
] |
45 changes: 45 additions & 0 deletions
45
src/open_inwoner/openzaak/migrations/0032_populate_zaaktype_urls.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Generated by Django 3.2.20 on 2023-11-14 11:26 | ||
|
||
from django.db import migrations | ||
from django.db import transaction | ||
from open_inwoner.openzaak.zgw_imports import get_configurable_zaaktypes | ||
from django.core.exceptions import ObjectDoesNotExist | ||
|
||
|
||
def populate_zaaktype_config_urls(apps, schema_editor): | ||
""" | ||
Go through configurable zaaktypen and populate the new URL field where needed | ||
""" | ||
ZaakTypeConfig = apps.get_model("openzaak", "ZaakTypeConfig") | ||
CatalogusConfig = apps.get_model("openzaak", "CatalogusConfig") | ||
catalog_lookup = {c.url: c for c in CatalogusConfig.objects.all()} | ||
|
||
zaaktypes = get_configurable_zaaktypes() | ||
if not zaaktypes: | ||
return [] | ||
|
||
with transaction.atomic(): | ||
for zaaktype in zaaktypes: | ||
catalog = catalog_lookup.get(zaaktype.catalogus) | ||
if not catalog: | ||
continue | ||
|
||
try: | ||
config = ZaakTypeConfig.objects.get( | ||
url="", catalogus=catalog, identificatie=zaaktype.identificatie | ||
) | ||
config.url = zaaktype.url | ||
config.save() | ||
except ObjectDoesNotExist: | ||
continue | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("openzaak", "0031_zaaktypeconfig_url"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(populate_zaaktype_config_urls, migrations.RunPython.noop), | ||
] |
18 changes: 18 additions & 0 deletions
18
src/open_inwoner/openzaak/migrations/0033_alter_zaaktypeconfig_url.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.20 on 2023-11-14 11:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("openzaak", "0032_populate_zaaktype_urls"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="zaaktypeconfig", | ||
name="url", | ||
field=models.URLField(unique=True, verbose_name="Zaaktype URL"), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters