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

The sidebar navigation link callback gets called once, and the request probably gets cached #356

Open
summerthe opened this issue Apr 17, 2024 · 0 comments

Comments

@summerthe
Copy link

summerthe commented Apr 17, 2024

Hi @lukasvinclav this issue is related to #300 where the request was getting cached.

I have a link callback in the sidebar navigation. The URL path of it changes based on the type of user. But there are possibly two problems:

def reverse_callback(request):
    print("request.user.is_superuser",request.user.is_superuser)
    if request.user.is_superuser:
        return reverse_lazy("admin:formula_driver_changelist")
    else:
        return reverse_lazy("admin:auth_group_changelist")

--------
{
 "title": _("Drivers"),
 "icon": "sports_motorsports",
 "link": reverse_callback,
}
  • The callback gets called only once after the user logs into the platform. The callback doesn't get called for further requests. Hence the url path doesn't change based on the callback.
  • It is possible the request might be getting cached as well. I couldn't test if the request is getting cached or not because the callback doesn't run the second time ever.

I have reproduced this issue in Formula Fork with latest unfold version 0.22. Check here summerthe/formula@b23d552

As a fix, for the superadmin, the callback should return the driver's URL with a print in the terminal. For the staff user group url and print in the terminal on each request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant