-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [#93] added admin pages for the new models
- Loading branch information
1 parent
f154ee0
commit 70edb3e
Showing
12 changed files
with
348 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .actoren import * # noqa | ||
from .digitaal_adres import * # noqa | ||
from .klantcontacten import * # noqa | ||
from .partijen import * # noqa |
44 changes: 44 additions & 0 deletions
44
src/openklant/components/klantinteracties/admin/actoren.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,44 @@ | ||
from django.contrib import admin | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from ..admin.internezaken import InterneTaakInlineAdmin | ||
from ..models.actoren import Actor | ||
|
||
|
||
@admin.register(Actor) | ||
class ActorAdmin(admin.ModelAdmin): | ||
list_display = [ | ||
"naam", | ||
"soort_actor", | ||
"indicatie_actief", | ||
] | ||
list_filter = [ | ||
"soort_actor", | ||
"indicatie_actief", | ||
] | ||
search_fields = ("naam",) | ||
inlines = [InterneTaakInlineAdmin] | ||
fieldsets = [ | ||
( | ||
None, | ||
{ | ||
"fields": [ | ||
"naam", | ||
"soort_actor", | ||
"indicatie_actief", | ||
] | ||
}, | ||
), | ||
( | ||
_("Objectidentificator velden"), | ||
{ | ||
"fields": [ | ||
"objectidentificator_objecttype", | ||
"objectidentificator_soort_object_id", | ||
"objectidentificator_object_id", | ||
"objectidentificator_register", | ||
] | ||
}, | ||
), | ||
] |
10 changes: 10 additions & 0 deletions
10
src/openklant/components/klantinteracties/admin/digitaal_adres.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,10 @@ | ||
from django.contrib import admin | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from ..models.digitaal_adres import DigitaalAdres | ||
|
||
|
||
@admin.register(DigitaalAdres) | ||
class DigitaalAdresAdmin(admin.ModelAdmin): | ||
search_fields = ("adres",) |
9 changes: 9 additions & 0 deletions
9
src/openklant/components/klantinteracties/admin/internezaken.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,9 @@ | ||
from django.contrib import admin | ||
|
||
from ..models.internetaken import InterneTaak | ||
|
||
|
||
class InterneTaakInlineAdmin(admin.StackedInline): | ||
model = InterneTaak | ||
extra = 0 | ||
autocomplete_fields = ("klantcontact",) |
116 changes: 116 additions & 0 deletions
116
src/openklant/components/klantinteracties/admin/klantcontacten.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,116 @@ | ||
from django.contrib import admin | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from ..admin.internezaken import InterneTaakInlineAdmin | ||
from ..models.klantcontacten import Klantcontact, Betrokkene, Onderwerpobject, Bijlage | ||
|
||
|
||
class BetrokkeneInlineAdmin(admin.StackedInline): | ||
model = Betrokkene | ||
search_fields = ( | ||
"contactnaam_voorletters", | ||
"contactnaam_voorvoegsel_achternaam", | ||
"contactnaam_achternaam", | ||
) | ||
fieldsets = [ | ||
( | ||
None, | ||
{ | ||
"fields": [ | ||
"klantcontact", | ||
"digitaal_adres", | ||
"rol", | ||
"organisatienaam", | ||
"initiator", | ||
] | ||
}, | ||
), | ||
( | ||
_("Bezoekadres velden"), | ||
{ | ||
"fields": [ | ||
"bezoekadres_nummeraanduiding_id", | ||
"bezoekadres_adresregel1", | ||
"bezoekadres_adresregel2", | ||
"bezoekadres_adresregel3", | ||
"bezoekadres_land", | ||
] | ||
}, | ||
), | ||
( | ||
_("Correspondentieadres velden"), | ||
{ | ||
"fields": [ | ||
"correspondentieadres_nummeraanduiding_id", | ||
"correspondentieadres_adresregel1", | ||
"correspondentieadres_adresregel2", | ||
"correspondentieadres_adresregel3", | ||
"correspondentieadres_land", | ||
] | ||
}, | ||
), | ||
( | ||
_("Contactnaam velden"), | ||
{ | ||
"fields": [ | ||
"contactnaam_voorletters", | ||
"contactnaam_voornaam", | ||
"contactnaam_voorvoegsel_achternaam", | ||
"contactnaam_achternaam", | ||
] | ||
}, | ||
), | ||
] | ||
extra = 0 | ||
|
||
|
||
@admin.register(Betrokkene) | ||
class BetrokkeneAdmin(admin.ModelAdmin): | ||
search_fields = ( | ||
"contactnaam_voorletters", | ||
"contactnaam_voorvoegsel_achternaam", | ||
"contactnaam_achternaam", | ||
) | ||
|
||
|
||
class OnderwerpobjectInlineAdmin(admin.StackedInline): | ||
model = Onderwerpobject | ||
fk_name = "klantcontact" | ||
extra = 0 | ||
|
||
|
||
class WasOnderwerpobjectInlineAdmin(admin.StackedInline): | ||
model = Onderwerpobject | ||
fk_name = "was_klantcontact" | ||
extra = 0 | ||
|
||
|
||
class BijlageInlineAdmin(admin.StackedInline): | ||
model = Bijlage | ||
extra = 0 | ||
|
||
|
||
@admin.register(Klantcontact) | ||
class KlantcontactAdmin(admin.ModelAdmin): | ||
list_display = ["nummer", "kanaal", "indicatie_contact_gelukt", "betrokkene_namen"] | ||
list_filter = [ | ||
"indicatie_contact_gelukt", | ||
] | ||
inlines = [ | ||
BetrokkeneInlineAdmin, | ||
OnderwerpobjectInlineAdmin, | ||
WasOnderwerpobjectInlineAdmin, | ||
BijlageInlineAdmin, | ||
InterneTaakInlineAdmin, | ||
] | ||
search_fields = ("nummer",) | ||
autocomplete_fields = ["actoren"] | ||
date_hierarchy = "plaatsgevonden_op" | ||
|
||
@admin.display(empty_value="---") | ||
def betrokkene_namen(self, obj): | ||
if betrokkene := obj.betrokkene_set.all(): | ||
return [person.get_contactnaam() for person in betrokkene] | ||
|
||
betrokkene_namen.short_description = _("betrokkene namen") |
106 changes: 106 additions & 0 deletions
106
src/openklant/components/klantinteracties/admin/partijen.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,106 @@ | ||
from django.contrib import admin | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from ..models.partijen import Partij, Persoon, Contactpersoon, Organisatie | ||
|
||
|
||
class PersoonInlineAdmin(admin.StackedInline): | ||
model = Persoon | ||
extra = 0 | ||
|
||
|
||
class ContactpersoonInlineAdmin(admin.StackedInline): | ||
model = Contactpersoon | ||
extra = 0 | ||
|
||
|
||
class OrganisatieInlineAdmin(admin.StackedInline): | ||
model = Organisatie | ||
extra = 0 | ||
|
||
|
||
@admin.register(Partij) | ||
class PartijAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"nummer", | ||
"get_contactpersoon", | ||
"get_personen", | ||
"get_organisatienaam", | ||
"soort_partij", | ||
"indicatie_actief", | ||
) | ||
list_filter = ( | ||
"soort_partij", | ||
"indicatie_actief", | ||
) | ||
inlines = (PersoonInlineAdmin, ContactpersoonInlineAdmin, OrganisatieInlineAdmin) | ||
autocomplete_fields = ( | ||
"betrokkene", | ||
"digitaal_adres", | ||
"voorkeurs_digitaal_adres", | ||
) | ||
fieldsets = [ | ||
( | ||
None, | ||
{ | ||
"fields": [ | ||
"betrokkene", | ||
"digitaal_adres", | ||
"voorkeurs_digitaal_adres", | ||
"vertegenwoordigde", | ||
"nummer", | ||
"interne_notitie", | ||
"soort_partij", | ||
"indicatie_geheimhouding", | ||
"voorkeurstaal", | ||
"indicatie_actief", | ||
] | ||
}, | ||
), | ||
( | ||
_("Bezoekadres velden"), | ||
{ | ||
"fields": [ | ||
"bezoekadres_nummeraanduiding_id", | ||
"bezoekadres_adresregel1", | ||
"bezoekadres_adresregel2", | ||
"bezoekadres_adresregel3", | ||
"bezoekadres_land", | ||
] | ||
}, | ||
), | ||
( | ||
_("Correspondentieadres velden"), | ||
{ | ||
"fields": [ | ||
"correspondentieadres_nummeraanduiding_id", | ||
"correspondentieadres_adresregel1", | ||
"correspondentieadres_adresregel2", | ||
"correspondentieadres_adresregel3", | ||
"correspondentieadres_land", | ||
] | ||
}, | ||
), | ||
] | ||
|
||
@admin.display(empty_value="---") | ||
def get_personen(self, obj): | ||
if people := obj.persoon_set.all(): | ||
return [person.get_contactnaam() for person in people] | ||
|
||
get_personen.short_description = _("personen") | ||
|
||
@admin.display(empty_value="---") | ||
def get_contactpersoon(self, obj): | ||
if people := obj.contactpersoon_set.all(): | ||
return [person.get_contactnaam() for person in people] | ||
|
||
get_contactpersoon.short_description = _("contact persoon") | ||
|
||
@admin.display(empty_value="---") | ||
def get_organisatienaam(self, obj): | ||
if organisaties := obj.organisatie_set.all(): | ||
return [organisatie.naam for organisatie in organisaties] | ||
|
||
get_organisatienaam.short_description = _("organisatienaam") |
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
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
Oops, something went wrong.