Skip to content

Conversation

adamantike
Copy link
Contributor

With this change, having a panel status set in the cookies exits earlier, as it isn't needed to retrieve the Django settings and panel name to calculate the default value.

With this change, having a panel status set in the cookies exits earlier, as it isn't needed to retrieve the Django settings and panel name to calculate the default value.
def enabled(self):
def enabled(self) -> bool:
# The user's cookies should override the default value
cookie_value = self.toolbar.request.COOKIES.get("djdt" + self.panel_id)
Copy link
Member

@tim-schilling tim-schilling Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user has enabled a panel (creating a cookie value of "on"), then changes their settings file to disable it, wouldn't this override the customized settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, that's the same behavior we have today, as the default value is only used when a cookie value is not found in the request.

This shouldn't change how a panel status is decided, just to return faster when the cookie is set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct. DebugToolbar.get_panel_classes is what I was worried about. I wanted to make sure that a developer was still able to stop using a panel even if the cookies are set.

@tim-schilling tim-schilling merged commit f138780 into django-commons:main Sep 25, 2022
@tim-schilling
Copy link
Member

Thank you for the PR!

@adamantike adamantike deleted the fix/simplify-panel-enabled-property branch October 17, 2022 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants