Skip to content

Commit

Permalink
Merge branch 'main' into StevenHosper/issue128
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenHosper authored Nov 4, 2024
2 parents f854b66 + f7d4458 commit a35fc24
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## 0.55 (unreleased)


- Nothing changed yet.
- Auto fill underPrivilige
- Correct tubeTopDiameter optionality


## 0.54 (2024-11-04)
Expand Down
3 changes: 0 additions & 3 deletions api/bro_upload/templates/registration_GAR.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<brocom:deliveryAccountableParty>{{ metadata.deliveryAccountableParty }}</brocom:deliveryAccountableParty>
{% endif %}
<brocom:qualityRegime>{{ metadata.qualityRegime }}</brocom:qualityRegime>
{% if metadata.underPrivilege %}
<brocom:underPrivilege>{{ metadata.underPrivilege }}</brocom:underPrivilege>
{% endif %}
<sourceDocument>
<GAR gml:id="id_0001">
<objectIdAccountableParty>{{ sourcedocs_data.objectIdAccountableParty }}</objectIdAccountableParty>
Expand Down
30 changes: 22 additions & 8 deletions api/bro_upload/upload_datamodels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from datetime import date, datetime

from pydantic import BaseModel, validator
from pydantic import BaseModel, root_validator, validator

## Uploadtask models

Expand All @@ -16,6 +16,16 @@ class UploadTaskMetadata(BaseModel):
correctionReason: str | None = None
dateToBeCorrected: str | date | None = None

@root_validator(pre=True)
def format_underPrivilege(cls, values):
# Check and set `underPrivilege`
if values.get("qualityRegime") == "IMBRO/A" and not values.get(
"underPrivilege"
):
values["underPrivilege"] = "ja"

return values


class GARBulkUploadMetadata(BaseModel):
requestReference: str
Expand Down Expand Up @@ -368,14 +378,18 @@ def format_measurementTimeseriesId(cls, value):
return f"_{uuid.uuid4()}"
return value

@validator("validationStatus", pre=True, always=True)
def format_validationStatus(cls, value):
@root_validator(pre=True)
def format_validationStatus(cls, values):
"""Ensure the measurementTimeseriesId is always filled with an uuid"""
if cls.observationType == "reguliereMeting" and not value:
return "onbekend"
elif cls.observationType == "controlemeting":
return None
return value
# Check and set `validationStatus`
if values.get("observationType") == "reguliereMeting" and not values.get(
"validationStatus"
):
values["validationStatus"] = "onbekend"
elif values.get("observationType") == "controlemeting":
values["validationStatus"] = None

return values


# FRD
Expand Down
1 change: 0 additions & 1 deletion api/management/commands/dawaco_gar_bulk_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def handle_gar_delivery(
"qualityRegime": "IMBRO/A", # hardcoded
"requestReference": "dawaco_export_gar_data_bulk_upload_brostar", # hardcoded
"deliveryAccountableParty": organisation_instance.kvk_number,
"underPrivilege": "ja",
}

uploadtask_sourcedocument_data: datamodels.GAR = setup_gar_sourcedocs_data(
Expand Down
3 changes: 0 additions & 3 deletions api/tests/test_gar_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<brocom:deliveryAccountableParty>test</brocom:deliveryAccountableParty>
<brocom:qualityRegime>IMBRO</brocom:qualityRegime>
<brocom:underPrivilege>ja</brocom:underPrivilege>
<sourceDocument>
<GAR gml:id="id_0001">
<objectIdAccountableParty>test</objectIdAccountableParty>
Expand Down

0 comments on commit a35fc24

Please sign in to comment.