Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

93533 #1162

Merged
merged 2 commits into from
Sep 29, 2023
Merged

93533 #1162

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions app/apps/permits/api_queries_decos_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ def get_decos_entry_by_bag_id(self, bag_id, dt):
}
for v in decos_join_conf_object
]
# Initialize an empty list to hold new items
new_permits = []

response_decos_obj = self.get_decos_object_with_bag_id(bag_id)

Expand Down Expand Up @@ -327,20 +329,48 @@ def get_decos_entry_by_bag_id(self, bag_id, dt):
# Wrap datetime validation in a try-catch to prevent breaking code.
try:
# Is the current permit valid/active? => now must be between start and enddate.
is_current_permit_valid = (
current_permit_valid_from <= now
and now <= current_permit_valid_until
)
# Check if the variables are not None before comparing.
if (
current_permit_valid_from is not None
and current_permit_valid_until
is not None
):
is_current_permit_valid = (
current_permit_valid_from <= now
and now
<= current_permit_valid_until
)
else:
# Handle the case where one or both variables are None
is_current_permit_valid = False

# Is the next permit valid/active? => now must be between start and enddate.
is_next_permit_valid = (
next_permit_valid_from <= now
and now <= next_permit_valid_until
)
# Check if the variables are not None before comparing.
if (
next_permit_valid_from is not None
and next_permit_valid_until is not None
):
is_next_permit_valid = (
next_permit_valid_from <= now
and now <= next_permit_valid_until
)
else:
# Handle the case where one or both variables are None
is_next_permit_valid = False

if is_next_permit_valid:
# Next permit is valid so this is the one users would like to see. Update permit data.
d.update(permit_serializer.data)
if is_current_permit_valid:
# Both current and next permits are valid.
# Show both permits so the Toezichthouder can decide.
# Add the next permit to the new_permits list for merging later.
new_permits.append(
permit_serializer.data
)
else:
# Only the next permit is valid, update the data.
d.update(permit_serializer.data)

elif not is_current_permit_valid:
# Current permit and next permit are not valid.
if next_permit_valid_from > now:
Expand Down Expand Up @@ -378,6 +408,9 @@ def get_decos_entry_by_bag_id(self, bag_id, dt):
"Config keys: %s" % decos_join_conf_object.get_book_keys()
)

# Extend the original permits list with new items
permits.extend(new_permits)

response.update(
{
"permits": permits,
Expand Down
1 change: 1 addition & 0 deletions app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
"text19": "HOLDER",
"subject1": "SUBJECT",
"text6": "ADDRESS",
"document_date": "REQUEST_DATE",
}
DECOS_JOIN_BOOK_UNKNOWN_BOOK = "B1FF791EA9FA44698D5ABBB1963B94EC"
DECOS_JOIN_BOOK_KNOWN_BAG_OBJECTS = "90642DCCC2DB46469657C3D0DF0B1ED7"
Expand Down
Loading