Coverage for product_risk_suite/threat_model/admin.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-07 12:45 +0000

1from django.contrib import admin 

2 

3from .models import ThreatModel, ThreatModelConnectionName 

4from product.models import Product 

5 

6class ThreatModelConnectionNameAdmin(admin.ModelAdmin): 

7 list_display = ["tech_name", "product", "human_name"] 

8 exclude = ('id', 'product_id') 

9 ordering = ['human_name'] 

10 

11 @admin.display(description='Product') 

12 def product(self, obj): 

13 return obj.product.title 

14 

15class ThreatModelAdmin(admin.ModelAdmin): 

16 list_display = ["product", "title", "description", "available_connections"] 

17 exclude = ('slug','connection_names') 

18 

19 @admin.display(description='Product') 

20 def product(self, obj): 

21 return obj.product.title 

22 

23 def available_connections(self, obj): 

24 return len(obj.connection_names.all()) 

25 

26 

27admin.site.register(ThreatModelConnectionName, ThreatModelConnectionNameAdmin) 

28admin.site.register(ThreatModel, ThreatModelAdmin)