Skip to content

Commit

Permalink
fix(edit-prod): Add assigned PT to queryset (#10843)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiblik authored Sep 6, 2024
1 parent 5c0e784 commit 8f54596
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dojo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ class ProductForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["prod_type"].queryset = get_authorized_product_types(Permissions.Product_Type_Add_Product)
if prod_type_id := getattr(kwargs.get("instance", Product()), "prod_type_id"): # we are editing existing instance
self.fields["prod_type"].queryset |= Product_Type.objects.filter(pk=prod_type_id) # even if user does not have permission for any other ProdType we need to add at least assign ProdType to make form submittable (otherwise empty list was here which generated invalid form)

# if this product has findings being asynchronously updated, disable the sla config field
if self.instance.async_updating:
Expand Down

0 comments on commit 8f54596

Please sign in to comment.