@@ -75,6 +75,7 @@ class Meta:
7575 "last_updated" ,
7676 "rule_count" ,
7777 )
78+ brief_fields = ("id" , "url" , "name" , "display" )
7879
7980 @extend_schema_field (serializers .DictField ())
8081 def get_assigned_object (self , obj ):
@@ -139,6 +140,7 @@ class Meta:
139140 "created" ,
140141 "last_updated" ,
141142 )
143+ brief_fields = ("id" , "url" , "access_list" )
142144
143145 @extend_schema_field (serializers .DictField ())
144146 def get_assigned_object (self , obj ):
@@ -212,6 +214,7 @@ class Meta:
212214 "last_updated" ,
213215 "source_prefix" ,
214216 )
217+ brief_fields = ("id" , "url" , "display" )
215218
216219 def validate (self , data ):
217220 """
@@ -221,14 +224,17 @@ def validate(self, data):
221224 """
222225 error_message = {}
223226
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+ ]
232238
233239 if error_message :
234240 raise serializers .ValidationError (error_message )
@@ -281,7 +287,7 @@ class Meta:
281287 "protocol" ,
282288 "remark" ,
283289 )
284-
290+ brief_fields = ( "id" , "url" , "display" )
285291 def validate (self , data ):
286292 """
287293 Validate the ACLExtendedRule django model's inputs before allowing it to update the instance:
@@ -295,34 +301,37 @@ def validate(self, data):
295301 """
296302 error_message = {}
297303
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+ ]
326335
327336 if error_message :
328337 raise serializers .ValidationError (error_message )
0 commit comments