Skip to content

Commit

Permalink
Merge pull request #1436 from open-zaak/feature/1435-verzending
Browse files Browse the repository at this point in the history
add Verzending resource
  • Loading branch information
annashamray committed Oct 23, 2023
2 parents d447d14 + 6e27ddc commit 1ca59a4
Show file tree
Hide file tree
Showing 17 changed files with 3,308 additions and 6 deletions.
89 changes: 89 additions & 0 deletions src/openzaak/components/documenten/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
EnkelvoudigInformatieObjectCanonical,
Gebruiksrechten,
ObjectInformatieObject,
Verzending,
)
from .views import PrivateMediaView
from .widgets import PrivateFileWidget
Expand Down Expand Up @@ -145,6 +146,85 @@ def get_queryset(self, request):
)


@admin.register(Verzending)
class VerzendingAdmin(UUIDAdminMixin, admin.ModelAdmin):
list_display = (
"uuid",
"aard_relatie",
"contactpersoonnaam",
"verzenddatum",
"ontvangstdatum",
)
list_filter = (
"aard_relatie",
"informatieobject",
)
ordering = (
"-verzenddatum",
"-ontvangstdatum",
)
search_fields = (
"contactpersoonnaam",
"uuid",
)
raw_id_fields = ("informatieobject",)

readonly_fields = ("uuid",)

fieldsets = (
(
_("Algemeen"),
{
"fields": (
"uuid",
"aard_relatie",
"toelichting",
"verzenddatum",
"ontvangstdatum",
"betrokkene",
"informatieobject",
),
},
),
(_("Contactpersoon"), {"fields": ("contact_persoon", "contactpersoonnaam",),},),
(
_("Afwijkend binnenlands correspondentieadres verzending"),
{
"fields": (
"binnenlands_correspondentieadres_huisletter",
"binnenlands_correspondentieadres_huisnummer",
"binnenlands_correspondentieadres_huisnummer_toevoeging",
"binnenlands_correspondentieadres_naam_openbare_ruimte",
"binnenlands_correspondentieadres_postcode",
"binnenlands_correspondentieadres_woonplaatsnaam",
),
},
),
(
_("Afwijkend buitenlands correspondentieadres verzending"),
{
"fields": (
"buitenlands_correspondentieadres_adres_buitenland_1",
"buitenlands_correspondentieadres_adres_buitenland_2",
"buitenlands_correspondentieadres_adres_buitenland_3",
"buitenlands_correspondentieadres_land_postadres",
),
},
),
(
_("Afwijkend correspondentie postadres verzending"),
{
"fields": (
"buitenlands_correspondentiepostadres_postbus_of_antwoord_nummer",
"buitenlands_correspondentiepostadres_postadres_postcode",
"buitenlands_correspondentiepostadres_postadrestype",
"buitenlands_correspondentiepostadres_woonplaatsnaam",
),
},
),
)


class GebruiksrechtenInline(EditInlineAdminMixin, admin.TabularInline):
model = Gebruiksrechten
fields = GebruiksrechtenAdmin.list_display
Expand All @@ -164,6 +244,12 @@ def get_object_display(self, obj):
get_object_display.short_description = "object"


class VerzendingInline(EditInlineAdminMixin, admin.TabularInline):
model = Verzending
fields = VerzendingAdmin.list_display
fk_name = "informatieobject"


class EnkelvoudigInformatieObjectInline(
AuditTrailInlineAdminMixin, PrivateMediaMixin, admin.StackedInline
):
Expand All @@ -190,6 +276,7 @@ class EnkelvoudigInformatieObjectCanonicalAdmin(AuditTrailAdminMixin, admin.Mode
EnkelvoudigInformatieObjectInline,
GebruiksrechtenInline,
ObjectInformatieObjectInline,
VerzendingInline,
]
actions = [unlock]

Expand Down Expand Up @@ -253,6 +340,7 @@ class EnkelvoudigInformatieObjectAdmin(
private_media_view_class = PrivateMediaView
private_media_file_widget = PrivateFileWidget
form = EnkelvoudigInformatieObjectForm
list_select_related = ("canonical",)

fieldsets = (
(
Expand Down Expand Up @@ -335,6 +423,7 @@ def get_object_actions(self, obj):
return (
link_to_related_objects(Gebruiksrechten, obj.canonical),
link_to_related_objects(ObjectInformatieObject, obj.canonical),
link_to_related_objects(Verzending, obj.canonical),
)


Expand Down
17 changes: 17 additions & 0 deletions src/openzaak/components/documenten/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
EnkelvoudigInformatieObjectCanonical,
Gebruiksrechten,
ObjectInformatieObject,
Verzending,
)
from .utils import check_path

Expand Down Expand Up @@ -103,3 +104,19 @@ def filter_queryset(self, queryset):
qs._result_cache = None
return qs
return super().filter_queryset(queryset)


class VerzendingFilter(FilterSet):
informatieobject = URLModelChoiceFilter(
queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
instance_path="canonical",
help_text=get_help_text("documenten.Verzending", "informatieobject"),
)

class Meta:
model = Verzending
fields = {
"aard_relatie": ["exact"],
"informatieobject": ["exact"],
"betrokkene": ["exact"],
}
92 changes: 92 additions & 0 deletions src/openzaak/components/documenten/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vng_api_common.constants import VertrouwelijkheidsAanduiding
from vng_api_common.serializers import (
GegevensGroepSerializer,
NestedGegevensGroepMixin,
add_choice_values_help_text,
)
from vng_api_common.utils import get_help_text
Expand All @@ -52,6 +53,7 @@
EnkelvoudigInformatieObjectCanonical,
Gebruiksrechten,
ObjectInformatieObject,
Verzending,
)
from ..query.cmis import flatten_gegevens_groep
from ..query.django import InformatieobjectRelatedQuerySet
Expand All @@ -63,6 +65,7 @@
InformatieObjectUniqueValidator,
StatusValidator,
UniekeIdentificatieValidator,
VerzendingAddressValidator,
)


Expand Down Expand Up @@ -991,3 +994,92 @@ def create(self, validated_data):

oio = super().create(validated_data)
return oio


# Verzending
class BinnenlandsCorrespondentieadresVerzendingSerializer(GegevensGroepSerializer):
class Meta:
model = Verzending
gegevensgroep = "binnenlands_correspondentieadres"


class BuitenlandsCorrespondentieadresVerzendingSerializer(GegevensGroepSerializer):
class Meta:
model = Verzending
gegevensgroep = "buitenlands_correspondentieadres"


class CorrespondentiePostadresVerzendingSerializer(GegevensGroepSerializer):
class Meta:
model = Verzending
gegevensgroep = "correspondentie_postadres"


class VerzendingSerializer(
NestedGegevensGroepMixin, serializers.HyperlinkedModelSerializer,
):
informatieobject = EnkelvoudigInformatieObjectHyperlinkedRelatedField(
view_name="enkelvoudiginformatieobject-detail",
lookup_field="uuid",
queryset=EnkelvoudigInformatieObject.objects,
help_text=get_help_text("documenten.Verzending", "informatieobject"),
)

binnenlands_correspondentieadres = BinnenlandsCorrespondentieadresVerzendingSerializer(
required=False,
allow_null=True,
help_text=_(
"Het correspondentieadres, betreffende een adresseerbaar object,"
" van de BETROKKENE, zijnde afzender of geadresseerde, zoals vermeld"
" in het ontvangen of verzonden INFORMATIEOBJECT indien dat afwijkt"
" van het reguliere binnenlandse correspondentieadres van BETROKKENE."
),
)

buitenlands_correspondentieadres = BuitenlandsCorrespondentieadresVerzendingSerializer(
required=False,
allow_null=True,
help_text=_(
"De gegevens van het adres in het buitenland van BETROKKENE, zijnde"
" afzender of geadresseerde, zoals vermeld in het ontvangen of"
" verzonden INFORMATIEOBJECT en dat afwijkt van de reguliere"
" correspondentiegegevens van BETROKKENE."
),
)

correspondentie_postadres = CorrespondentiePostadresVerzendingSerializer(
required=False,
allow_null=True,
help_text=_(
"De gegevens die tezamen een postbusadres of antwoordnummeradres"
" vormen van BETROKKENE, zijnde afzender of geadresseerde, zoals"
" vermeld in het ontvangen of verzonden INFORMATIEOBJECT en dat"
" afwijkt van de reguliere correspondentiegegevens van BETROKKENE."
),
)

class Meta:
model = Verzending
fields = (
"url",
"betrokkene",
"informatieobject",
"aard_relatie",
"toelichting",
"ontvangstdatum",
"verzenddatum",
"contact_persoon",
"contactpersoonnaam",
"binnenlands_correspondentieadres",
"buitenlands_correspondentieadres",
"correspondentie_postadres",
"faxnummer",
"emailadres",
"mijn_overheid",
"telefoonnummer",
)

extra_kwargs = {
"url": {"lookup_field": "uuid", "read_only": True},
}
validators = [VerzendingAddressValidator()]
2 changes: 2 additions & 0 deletions src/openzaak/components/documenten/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
EnkelvoudigInformatieObjectViewSet,
GebruiksrechtenViewSet,
ObjectInformatieObjectViewSet,
VerzendingViewSet,
)

router = routers.DefaultRouter()
Expand All @@ -26,6 +27,7 @@
router.register("gebruiksrechten", GebruiksrechtenViewSet)
router.register("objectinformatieobjecten", ObjectInformatieObjectViewSet)
router.register("bestandsdelen", BestandsDeelViewSet)
router.register("verzendingen", VerzendingViewSet)


# set the path to schema file
Expand Down

0 comments on commit 1ca59a4

Please sign in to comment.