Skip to content
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

Support the use of NetBox's generic views by plugins #8334

Closed
Tracked by #8333
jeremystretch opened this issue Jan 12, 2022 · 9 comments
Closed
Tracked by #8333

Support the use of NetBox's generic views by plugins #8334

jeremystretch opened this issue Jan 12, 2022 · 9 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

jeremystretch commented Jan 12, 2022

NetBox version

v3.1.5

Feature type

New functionality

Proposed functionality

Formally support and document the use of NetBox's generic view classes by plugins. These are to include initially:

  • ObjectView
  • ObjectEditView
  • ObjectDeleteView
  • ObjectListView
  • BulkImportView
  • BulkEditView
  • BulkDeleteView

Additional views may also be added or created depending on feedback from plugin authors.

Most of these classes likely must undergo so amount of refactoring and formalization to ensure a degree of maturity suitable for the inclusion in a public framework.

Use case

Much like Django's own generic views, use of these views enables plugin authors to avoid writing a substantial amount of boilerplate code.

Database changes

No response

External dependencies

No response

@jeremystretch jeremystretch added the type: feature Introduction of new functionality to the application label Jan 12, 2022
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Jan 12, 2022
@jeremystretch jeremystretch added this to the v3.2 milestone Jan 12, 2022
@jeremystretch jeremystretch added the topic: plugins Relates to the plugins framework label Jan 12, 2022
@johannwagner
Copy link

Hey,

we actually implemented this functionality within a quite hacky plugin our my employer. We could contribute an initial implementation. Is this the desired approach?

Best Regards,
Johann

@jeremystretch jeremystretch self-assigned this Jan 20, 2022
@jeremystretch
Copy link
Member Author

@johannwagner I think for the most part this amounts to "hardening" the existing view classes to make them suitable for use outside NetBox core. I'd be interested to see what changes you made. Is there a way you could share a summary, short of drafting a whole PR?

@johannwagner
Copy link

Mostly it's fixing up the url names because of the plugin prefix. The rest "just works" but lacks a lot of documentation, because the public use wasn't intended yet.

@jeremystretch
Copy link
Member Author

@johannwagner Roger. I know @DanSheps was working on that recently in the 6221-pluginviews branch; does that look similar to your tweaks?

@johannwagner
Copy link

Yup, we have similar patches, I just looked it up.
We have patches for:

  • viewname and validated_viewname template tags for the plugin prefix
  • ButtonsColumn also to implement the plugin prefix.

Those patches enables us to write plugin with newly introduced models with almost no boilerplate. Most boilerplate code comes from the <modelname>.html of the generic object view, which could be eliminated by some finer block overrides.

@johannwagner
Copy link

I also would like to see a better method of using different tabs within a detailed view, this is kinda hacky right now.

@DanSheps
Copy link
Member

Yeah, now that I see you are going the mkdocstring for documenting the API, I will work on cleaning up the view documentation

@jeremystretch
Copy link
Member Author

@DanSheps I've started on this in the 8334-plugin-views branch. I still have some work to do around refactoring & documentation; once that's done I'll fold in your changes from #6221. Then we can reassess scope and decide if there's anything else we need to add for #8334 specifically. Sound good?

@DanSheps
Copy link
Member

Sounds good with me. I will look into the button class thing, I think I might have covered that, I just need to double check.

jeremystretch added a commit that referenced this issue Jan 21, 2022
Closes #8334: Formally support use of generic views by plugins
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

3 participants