@@ -500,12 +500,6 @@ def get_context_data(self, **kwargs):
500
500
501
501
context = super ().get_context_data (** kwargs )
502
502
503
- context ["has_change_productcomponent_permission" ] = user .has_perm (
504
- "product_portfolio.change_productcomponent"
505
- )
506
- context ["has_change_productpackage_permission" ] = user .has_perm (
507
- "product_portfolio.change_productpackage"
508
- )
509
503
context ["has_change_codebaseresource_permission" ] = user .has_perm (
510
504
"product_portfolio.change_codebaseresource"
511
505
)
@@ -521,7 +515,7 @@ def get_context_data(self, **kwargs):
521
515
522
516
context ["has_edit_productpackage" ] = all (
523
517
[
524
- context [ "has_change_productpackage_permission" ] ,
518
+ user . has_perm ( "product_portfolio.change_productpackage" ) ,
525
519
context ["has_change_permission" ],
526
520
]
527
521
)
@@ -537,7 +531,7 @@ def get_context_data(self, **kwargs):
537
531
)
538
532
context ["has_edit_productcomponent" ] = all (
539
533
[
540
- context [ "has_change_productcomponent_permission" ] ,
534
+ user . has_perm ( "product_portfolio.change_productcomponent" ) ,
541
535
context ["has_change_permission" ],
542
536
]
543
537
)
@@ -588,7 +582,7 @@ class ProductTabInventoryView(
588
582
tab_id = "inventory"
589
583
590
584
def get_context_data (self , ** kwargs ):
591
- context_data = super ().get_context_data (** kwargs )
585
+ context = super ().get_context_data (** kwargs )
592
586
593
587
user = self .request .user
594
588
dataspace = user .dataspace
@@ -698,9 +692,9 @@ def get_context_data(self, **kwargs):
698
692
if isinstance (inventory_item , ProductPackage )
699
693
]
700
694
701
- context_data ["vulnerable_purls" ] = vulnerablecode .get_vulnerable_purls (packages )
695
+ context ["vulnerable_purls" ] = vulnerablecode .get_vulnerable_purls (packages )
702
696
703
- context_data .update (
697
+ context .update (
704
698
{
705
699
"filter_productcomponent" : filter_productcomponent ,
706
700
"inventory_items" : dict (objects_by_feature .items ()),
@@ -709,16 +703,31 @@ def get_context_data(self, **kwargs):
709
703
}
710
704
)
711
705
706
+ perms = guardian_get_perms (user , self .object )
707
+ has_product_change_permission = "change_product" in perms
708
+ context ["has_edit_productcomponent" ] = all (
709
+ [
710
+ has_product_change_permission ,
711
+ user .has_perm ("product_portfolio.change_productcomponent" ),
712
+ ]
713
+ )
714
+ context ["has_edit_productpackage" ] = all (
715
+ [
716
+ has_product_change_permission ,
717
+ user .has_perm ("product_portfolio.change_productpackage" ),
718
+ ]
719
+ )
720
+
712
721
if page_obj :
713
722
previous_url , next_url = self .get_previous_next (page_obj )
714
- context_data .update (
723
+ context .update (
715
724
{
716
725
"previous_url" : (previous_url or "" ) + f"#{ self .tab_id } " ,
717
726
"next_url" : (next_url or "" ) + f"#{ self .tab_id } " ,
718
727
}
719
728
)
720
729
721
- return context_data
730
+ return context
722
731
723
732
@staticmethod
724
733
def inject_scan_data (scancodeio , feature_grouped , dataspace_uuid ):
0 commit comments