Commit cc4d645 1 parent e50fd60 commit cc4d645 Copy full SHA for cc4d645
File tree 5 files changed +126
-0
lines changed
klantinteracties/api/serializers
5 files changed +126
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,19 @@ class Meta:
77
77
model = Organisatie
78
78
gegevensgroep = "adres"
79
79
80
+ def validate (self , attrs ):
81
+ if any (attrs .values ()):
82
+ if not attrs .get ("nummeraanduiding_id" ):
83
+ raise serializers .ValidationError (
84
+ {
85
+ "nummeraanduiding_id" : _ (
86
+ "nummeraanduiding_id is verplicht wanneer het adres ingevuld is."
87
+ ),
88
+ }
89
+ )
90
+
91
+ return super ().validate (attrs )
92
+
80
93
81
94
class OrganisatieSerializer (
82
95
NestedGegevensGroepMixin ,
@@ -141,6 +154,19 @@ class Meta:
141
154
model = Persoon
142
155
gegevensgroep = "adres"
143
156
157
+ def validate (self , attrs ):
158
+ if any (attrs .values ()):
159
+ if not attrs .get ("nummeraanduiding_id" ):
160
+ raise serializers .ValidationError (
161
+ {
162
+ "nummeraanduiding_id" : _ (
163
+ "nummeraanduiding_id is verplicht wanneer het adres ingevuld is."
164
+ ),
165
+ }
166
+ )
167
+
168
+ return super ().validate (attrs )
169
+
144
170
145
171
class PersoonSerializer (
146
172
NestedGegevensGroepMixin ,
Original file line number Diff line number Diff line change
1
+ # Generated by Django 3.2.23 on 2024-01-10 11:36
2
+
3
+ from django .db import migrations , models
4
+
5
+
6
+ class Migration (migrations .Migration ):
7
+ dependencies = [
8
+ ("contactgegevens" , "0001_initial" ),
9
+ ]
10
+
11
+ operations = [
12
+ migrations .AddField (
13
+ model_name = "organisatie" ,
14
+ name = "adres_nummeraanduiding_id" ,
15
+ field = models .CharField (
16
+ blank = True ,
17
+ help_text = "Identificatie van het adres bij de Basisregistratie Adressen en Gebouwen." ,
18
+ max_length = 255 ,
19
+ verbose_name = "nummeraanduiding ID" ,
20
+ ),
21
+ ),
22
+ migrations .AddField (
23
+ model_name = "persoon" ,
24
+ name = "adres_nummeraanduiding_id" ,
25
+ field = models .CharField (
26
+ blank = True ,
27
+ help_text = "Identificatie van het adres bij de Basisregistratie Adressen en Gebouwen." ,
28
+ max_length = 255 ,
29
+ verbose_name = "nummeraanduiding ID" ,
30
+ ),
31
+ ),
32
+ ]
Original file line number Diff line number Diff line change 6
6
7
7
8
8
class AdresMixin (models .Model ):
9
+ adres_nummeraanduiding_id = models .CharField (
10
+ _ ("nummeraanduiding ID" ),
11
+ help_text = _ (
12
+ "Identificatie van het adres bij de Basisregistratie Adressen en Gebouwen."
13
+ ),
14
+ max_length = 255 ,
15
+ blank = True ,
16
+ )
9
17
adres_adresregel1 = models .CharField (
10
18
_ ("adresregel 1" ),
11
19
help_text = _ (
@@ -46,11 +54,19 @@ class AdresMixin(models.Model):
46
54
47
55
adres = GegevensGroepType (
48
56
{
57
+ "nummeraanduiding_id" : adres_nummeraanduiding_id ,
49
58
"adresregel_1" : adres_adresregel1 ,
50
59
"adresregel_2" : adres_adresregel2 ,
51
60
"adresregel_3" : adres_adresregel3 ,
52
61
"land" : adres_land ,
53
62
},
63
+ optional = (
64
+ "nummeraanduiding_id" ,
65
+ "adresregel_1" ,
66
+ "adresregel_2" ,
67
+ "adresregel_3" ,
68
+ "land" ,
69
+ ),
54
70
)
55
71
56
72
class Meta :
Original file line number Diff line number Diff line change @@ -123,13 +123,39 @@ class Meta:
123
123
model = Betrokkene
124
124
gegevensgroep = "bezoekadres"
125
125
126
+ def validate (self , attrs ):
127
+ if any (attrs .values ()):
128
+ if not attrs .get ("nummeraanduiding_id" ):
129
+ raise serializers .ValidationError (
130
+ {
131
+ "nummeraanduiding_id" : _ (
132
+ "nummeraanduiding_id is verplicht wanneer het bezoekadres ingevuld is."
133
+ ),
134
+ }
135
+ )
136
+
137
+ return super ().validate (attrs )
138
+
126
139
127
140
class CorrespondentieadresSerializer (GegevensGroepSerializer ):
128
141
class Meta :
129
142
model = Betrokkene
130
143
gegevensgroep = "correspondentieadres"
131
144
ref_name = "betrokkene correspondentieadres"
132
145
146
+ def validate (self , attrs ):
147
+ if any (attrs .values ()):
148
+ if not attrs .get ("nummeraanduiding_id" ):
149
+ raise serializers .ValidationError (
150
+ {
151
+ "nummeraanduiding_id" : _ (
152
+ "nummeraanduiding_id is verplicht wanneer het correspondentieadres ingevuld is."
153
+ ),
154
+ }
155
+ )
156
+
157
+ return super ().validate (attrs )
158
+
133
159
134
160
class ContactnaamSerializer (GegevensGroepSerializer ):
135
161
class Meta :
Original file line number Diff line number Diff line change @@ -99,13 +99,39 @@ class Meta:
99
99
model = Partij
100
100
gegevensgroep = "bezoekadres"
101
101
102
+ def validate (self , attrs ):
103
+ if any (attrs .values ()):
104
+ if not attrs .get ("nummeraanduiding_id" ):
105
+ raise serializers .ValidationError (
106
+ {
107
+ "nummeraanduiding_id" : _ (
108
+ "nummeraanduiding_id is verplicht wanneer het bezoekadres ingevuld is."
109
+ ),
110
+ }
111
+ )
112
+
113
+ return super ().validate (attrs )
114
+
102
115
103
116
class CorrespondentieadresSerializer (GegevensGroepSerializer ):
104
117
class Meta :
105
118
model = Partij
106
119
gegevensgroep = "correspondentieadres"
107
120
ref_name = "partij correspondentieadres serializer"
108
121
122
+ def validate (self , attrs ):
123
+ if any (attrs .values ()):
124
+ if not attrs .get ("nummeraanduiding_id" ):
125
+ raise serializers .ValidationError (
126
+ {
127
+ "nummeraanduiding_id" : _ (
128
+ "nummeraanduiding_id is verplicht wanneer het correspondentieadres ingevuld is."
129
+ ),
130
+ }
131
+ )
132
+
133
+ return super ().validate (attrs )
134
+
109
135
110
136
class OrganisatieSerializer (serializers .ModelSerializer ):
111
137
class Meta :
You can’t perform that action at this time.
0 commit comments