-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fixes: #16144 GetReturnURLMixin Support for Plugin Views #18996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes: #16144 GetReturnURLMixin Support for Plugin Views #18996
Conversation
jeremystretch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simplify the logic here to avoid duplicating the view name?
netbox/utilities/views.py
Outdated
| # Attempt to dynamically resolve the list view for the object | ||
| if hasattr(self, 'queryset'): | ||
| model_opts = self.queryset.model._meta | ||
| is_plugin = isinstance(self.queryset.model._meta.app_config, PluginConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| is_plugin = isinstance(self.queryset.model._meta.app_config, PluginConfig) | |
| prefix = 'plugins:' if isinstance(self.queryset.model._meta.app_config, PluginConfig) else '' |
netbox/utilities/views.py
Outdated
| if is_plugin: | ||
| return reverse(f'plugins:{model_opts.app_label}:{model_opts.model_name}_list') | ||
| else: | ||
| return reverse(f'{model_opts.app_label}:{model_opts.model_name}_list') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if is_plugin: | |
| return reverse(f'plugins:{model_opts.app_label}:{model_opts.model_name}_list') | |
| else: | |
| return reverse(f'{model_opts.app_label}:{model_opts.model_name}_list') | |
| return reverse(f'{prefix}{model_opts.app_label}:{model_opts.model_name}_list') |
|
@jeremystretch since |
Fixes: #16144 GetReturnURLMixin Support for Plugin Views
querysetuse case ofGetReturnURLMixin