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

Notes and ChangeLog tabs using wrong model templates #2509

Closed
Kircheneer opened this issue Sep 28, 2022 · 1 comment · Fixed by #2522
Closed

Notes and ChangeLog tabs using wrong model templates #2509

Kircheneer opened this issue Sep 28, 2022 · 1 comment · Fixed by #2522
Assignees
Labels
type: bug Something isn't working as expected

Comments

@Kircheneer
Copy link
Contributor

Environment

  • Nautobot version (Docker tag too if applicable): 1.4.1
  • Python version: 3.10.4
  • Database platform, version: Docker image postgres:13-alpine
  • Middleware(s): -

Steps to Reproduce

  1. Create a model in a plugin
  2. Call the basic retrieve template for it $(MODELNAME)_retrieve (as I assume is best practice due to NautobotUIViewSet using this)
  3. Create an instance of that model
  4. Navigate to the Notes or Changelog tab of that model

Expected Behavior

The tab displays correctly including the rendering of the other tabs.

Observed Behavior

Only the tab content renders, not the other tabs.

image

Potential fix

Notes

A potential fix for the Notes issue could be here:

-       # Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
+       # Default to using "<app>/<model>_retrieve.html" as the template, if it exists. Otherwise,
        # fall back to using base.html.
        if self.base_template is None:
-           self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"
+           self.base_template = f"{model._meta.app_label}/{model._meta.model_name}_retrieve.html"
            # TODO: This can be removed once an object view has been established for every model.
            try:
                template.loader.get_template(self.base_template)
            except template.TemplateDoesNotExist:
                self.base_template = "base.html"

Changelog

A potential fix for the Changelog issue could be here:

-       # Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
+       # Default to using "<app>/<model>_retrieve.html" as the template, if it exists. Otherwise,
        # fall back to using base.html.
        if self.base_template is None:
-           self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"
+           self.base_template = f"{model._meta.app_label}/{model._meta.model_name}_retrieve.html"
            # TODO: This can be removed once an object view has been established for every model.
            try:
                template.loader.get_template(self.base_template)
            except template.TemplateDoesNotExist:
                self.base_template = "base.html"
@glennmatthews
Copy link
Contributor

We probably need logic to look for both filenames, as any existing views and plugins not using NautobotUIViewSet are likely still using the older <app_label>/<model_name>.html format still.

@glennmatthews glennmatthews added the type: bug Something isn't working as expected label Sep 28, 2022
@HanlinMiao HanlinMiao self-assigned this Sep 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants