@@ -75,6 +75,7 @@ class Meta:
75
75
"last_updated" ,
76
76
"rule_count" ,
77
77
)
78
+ brief_fields = ("id" , "url" , "name" , "display" )
78
79
79
80
@extend_schema_field (serializers .DictField ())
80
81
def get_assigned_object (self , obj ):
@@ -139,6 +140,7 @@ class Meta:
139
140
"created" ,
140
141
"last_updated" ,
141
142
)
143
+ brief_fields = ("id" , "url" , "access_list" )
142
144
143
145
@extend_schema_field (serializers .DictField ())
144
146
def get_assigned_object (self , obj ):
@@ -212,6 +214,7 @@ class Meta:
212
214
"last_updated" ,
213
215
"source_prefix" ,
214
216
)
217
+ brief_fields = ("id" , "url" , "display" )
215
218
216
219
def validate (self , data ):
217
220
"""
@@ -221,14 +224,17 @@ def validate(self, data):
221
224
"""
222
225
error_message = {}
223
226
224
- # Check if action set to remark, but no remark set.
225
- if data .get ("action" ) == "remark" and data .get ("remark" ) is None :
226
- error_message ["remark" ] = [error_message_no_remark ]
227
- # Check if action set to remark, but source_prefix set.
228
- if data .get ("source_prefix" ):
229
- error_message ["source_prefix" ] = [
230
- error_message_action_remark_source_prefix_set ,
231
- ]
227
+ if data .get ("action" ) == "remark" :
228
+ # Check if action set to remark, but no remark set.
229
+ if data .get ("remark" ) is None :
230
+ error_message ["remark" ] = [
231
+ error_message_no_remark ,
232
+ ]
233
+ # Check if action set to remark, but source_prefix set.
234
+ if data .get ("source_prefix" ):
235
+ error_message ["source_prefix" ] = [
236
+ error_message_action_remark_source_prefix_set ,
237
+ ]
232
238
233
239
if error_message :
234
240
raise serializers .ValidationError (error_message )
@@ -281,7 +287,7 @@ class Meta:
281
287
"protocol" ,
282
288
"remark" ,
283
289
)
284
-
290
+ brief_fields = ( "id" , "url" , "display" )
285
291
def validate (self , data ):
286
292
"""
287
293
Validate the ACLExtendedRule django model's inputs before allowing it to update the instance:
@@ -295,34 +301,37 @@ def validate(self, data):
295
301
"""
296
302
error_message = {}
297
303
298
- # Check if action set to remark, but no remark set.
299
- if data .get ("action" ) == "remark" and data .get ("remark" ) is None :
300
- error_message ["remark" ] = [error_message_no_remark ]
301
- # Check if action set to remark, but source_prefix set.
302
- if data .get ("source_prefix" ):
303
- error_message ["source_prefix" ] = [
304
- error_message_action_remark_source_prefix_set ,
305
- ]
306
- # Check if action set to remark, but source_ports set.
307
- if data .get ("source_ports" ):
308
- error_message ["source_ports" ] = [
309
- "Action is set to remark, Source Ports CANNOT be set." ,
310
- ]
311
- # Check if action set to remark, but destination_prefix set.
312
- if data .get ("destination_prefix" ):
313
- error_message ["destination_prefix" ] = [
314
- "Action is set to remark, Destination Prefix CANNOT be set." ,
315
- ]
316
- # Check if action set to remark, but destination_ports set.
317
- if data .get ("destination_ports" ):
318
- error_message ["destination_ports" ] = [
319
- "Action is set to remark, Destination Ports CANNOT be set." ,
320
- ]
321
- # Check if action set to remark, but protocol set.
322
- if data .get ("protocol" ):
323
- error_message ["protocol" ] = [
324
- "Action is set to remark, Protocol CANNOT be set." ,
325
- ]
304
+ if data .get ("action" ) == "remark" :
305
+ # Check if action set to remark, but no remark set.
306
+ if data .get ("remark" ) is None :
307
+ error_message ["remark" ] = [
308
+ error_message_no_remark ,
309
+ ]
310
+ # Check if action set to remark, but source_prefix set.
311
+ if data .get ("source_prefix" ):
312
+ error_message ["source_prefix" ] = [
313
+ error_message_action_remark_source_prefix_set ,
314
+ ]
315
+ # Check if action set to remark, but source_ports set.
316
+ if data .get ("source_ports" ):
317
+ error_message ["source_ports" ] = [
318
+ "Action is set to remark, Source Ports CANNOT be set." ,
319
+ ]
320
+ # Check if action set to remark, but destination_prefix set.
321
+ if data .get ("destination_prefix" ):
322
+ error_message ["destination_prefix" ] = [
323
+ "Action is set to remark, Destination Prefix CANNOT be set." ,
324
+ ]
325
+ # Check if action set to remark, but destination_ports set.
326
+ if data .get ("destination_ports" ):
327
+ error_message ["destination_ports" ] = [
328
+ "Action is set to remark, Destination Ports CANNOT be set." ,
329
+ ]
330
+ # Check if action set to remark, but protocol set.
331
+ if data .get ("protocol" ):
332
+ error_message ["protocol" ] = [
333
+ "Action is set to remark, Protocol CANNOT be set." ,
334
+ ]
326
335
327
336
if error_message :
328
337
raise serializers .ValidationError (error_message )
0 commit comments