File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def validate(self, data):
5151 if self .instance is not None and not data .get ("role" ).is_owner :
5252 owners = (
5353 Product_Type_Member .objects .filter (
54- product_type = data .get ("organization" ), role__is_owner = True ,
54+ product_type = data .get ("organization" , data . get ( "product_type" ) ), role__is_owner = True ,
5555 )
5656 .exclude (id = self .instance .id )
5757 .count ()
@@ -115,8 +115,8 @@ def validate(self, data):
115115
116116
117117class OrganizationSerializer (serializers .ModelSerializer ):
118- critical_asset = serializers .BooleanField (source = "critical_product" )
119- key_asset = serializers .BooleanField (source = "key_product" )
118+ critical_asset = serializers .BooleanField (source = "critical_product" , default = False )
119+ key_asset = serializers .BooleanField (source = "key_product" , default = False )
120120
121121 class Meta :
122122 model = Product_Type
Original file line number Diff line number Diff line change 1717)
1818from dojo .organization .api import serializers
1919from dojo .organization .api .filters import (
20+ OrganizationFilterSet ,
2021 OrganizationGroupFilterSet ,
2122 OrganizationMemberFilterSet ,
2223)
@@ -36,14 +37,7 @@ class OrganizationViewSet(
3637 serializer_class = serializers .OrganizationSerializer
3738 queryset = Product_Type .objects .none ()
3839 filter_backends = (DjangoFilterBackend ,)
39- filterset_fields = [
40- "id" ,
41- "name" ,
42- "critical_product" ,
43- "key_product" ,
44- "created" ,
45- "updated" ,
46- ]
40+ filterset_class = OrganizationFilterSet
4741 permission_classes = (
4842 IsAuthenticated ,
4943 permissions .UserHasProductTypePermission ,
@@ -60,6 +54,9 @@ def perform_create(self, serializer):
6054 product_type_data = serializer .data
6155 product_type_data .pop ("authorization_groups" )
6256 product_type_data .pop ("members" )
57+ # Manage custom fields separately with default fields of false
58+ product_type_data ["critical_product" ] = product_type_data .pop ("critical_asset" , False )
59+ product_type_data ["key_product" ] = product_type_data .pop ("key_asset" , False )
6360 member = Product_Type_Member ()
6461 member .user = self .request .user
6562 member .product_type = Product_Type (** product_type_data )
You can’t perform that action at this time.
0 commit comments