Skip to content

Commit

Permalink
96116
Browse files Browse the repository at this point in the history
  • Loading branch information
remyvdwereld committed Oct 20, 2023
1 parent f751ff4 commit 0b2b893
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/apps/addresses/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from django.db import models
from utils.api_queries_bag import (
do_bag_search_by_bag_id,
Expand All @@ -6,6 +8,8 @@
get_bag_data_by_verblijfsobject_url,
)

logger = logging.getLogger(__name__)


class District(models.Model):
name = models.CharField(max_length=255, unique=True)
Expand Down Expand Up @@ -162,6 +166,13 @@ def search_and_set_bag_nummeraanduiding_id(self):

def save(self, *args, **kwargs):
self.search_and_set_bag_address_data()
self.search_and_set_bag_nummeraanduiding_id()
# Prevent a nummeraanduiding_id error while creating a case.
try:
self.search_and_set_bag_nummeraanduiding_id()
except Exception as e:
logger.error(
f"Could not retrieve nummeraanduiding_id for bag_id:{self.bag_id}: {e}"
)

# TODO: If self is missing address data, don't create a case.
return super().save(*args, **kwargs)

0 comments on commit 0b2b893

Please sign in to comment.