1212
1313
1414class BaseOwaspAdminMixin :
15- """
16- Base mixin for OWASP admin classes.
15+ """Base mixin for OWASP admin classes.
1716
1817 Provides common configuration patterns—such as default list_display,
1918 list_filter, and search_fields—so individual ModelAdmin classes can avoid
@@ -86,19 +85,10 @@ class EntityChannelInline(GenericTabularInline):
8685 ordering = ("platform" , "channel_id" )
8786
8887 def formfield_for_dbfield (self , db_field , request , ** kwargs ):
89- """
90- Customize form widgets for EntityChannel inline fields.
88+ """Customize form widgets for EntityChannel inline fields.
9189
9290 - Uses a custom ChannelIdWidget for the channel_id field.
9391 - Limits channel_type choices to only Slack Conversation content types.
94-
95- Args:
96- db_field (Field): The model field being rendered.
97- request (HttpRequest): The current request.
98- **kwargs: Additional keyword arguments passed to the widget.
99-
100- Returns:
101- FormField: The configured form field instance.
10292 """
10393 if db_field .name == "channel_id" :
10494 kwargs ["widget" ] = ChannelIdWidget ()
@@ -112,16 +102,14 @@ def formfield_for_dbfield(self, db_field, request, **kwargs):
112102
113103
114104class GenericEntityAdminMixin (BaseOwaspAdminMixin ):
115- """
116- Mixin providing common rendering logic for OWASP entity admin views.
105+ """Mixin providing common rendering logic for OWASP entity admin views.
117106
118107 Adds helpers for displaying GitHub and OWASP links and prefetches related
119108 repositories for performance.
120109 """
121110
122111 def get_queryset (self , request ):
123- """
124- Extend the base queryset to prefetch related repositories.
112+ """Extend the base queryset to prefetch related repositories.
125113
126114 This reduces SQL queries when displaying GitHub-related fields.
127115
@@ -134,18 +122,11 @@ def get_queryset(self, request):
134122 return super ().get_queryset (request ).prefetch_related ("repositories" )
135123
136124 def custom_field_github_urls (self , obj ):
137- """
138- Render GitHub URLs for the associated entity.
125+ """Render GitHub URLs for the associated entity.
139126
140127 Handles:
141128 - Entities with multiple repositories (uses obj.repositories)
142129 - Entities with a single owasp_repository field
143-
144- Args:
145- obj: The entity instance.
146-
147- Returns:
148- str: HTML-safe formatted GitHub links.
149130 """
150131 if not hasattr (obj , "repositories" ):
151132 if not hasattr (obj , "owasp_repository" ) or not obj .owasp_repository :
@@ -159,15 +140,7 @@ def custom_field_github_urls(self, obj):
159140 )
160141
161142 def custom_field_owasp_url (self , obj ):
162- """
163- Render a link to the official OWASP entity webpage.
164-
165- Args:
166- obj: The entity instance.
167-
168- Returns:
169- str: HTML-safe link to https://owasp.org/<entity_key>.
170- """
143+ """Render a link to the official OWASP entity webpage."""
171144 if not hasattr (obj , "key" ) or not obj .key :
172145 return ""
173146
@@ -176,16 +149,7 @@ def custom_field_owasp_url(self, obj):
176149 )
177150
178151 def _format_github_link (self , repository ):
179- """
180- Format a GitHub repository link consistently.
181-
182- Args:
183- repository: A repository instance with owner.login and key attributes.
184-
185- Returns:
186- str: HTML-safe anchor tag linking to the GitHub repo, or empty string
187- if required fields are missing.
188- """
152+ """Format a GitHub repository link consistently."""
189153 if not repository or not hasattr (repository , "owner" ) or not repository .owner :
190154 return ""
191155 if not hasattr (repository .owner , "login" ) or not repository .owner .login :
@@ -203,8 +167,7 @@ def _format_github_link(self, repository):
203167
204168
205169class StandardOwaspAdminMixin (BaseOwaspAdminMixin ):
206- """
207- Simple mixin for OWASP admin classes.
170+ """Simple mixin for OWASP admin classes.
208171
209172 Provides convenient helpers for generating common admin config
210173 (list_display, list_filter, search_fields).
0 commit comments