mbi / django-rosetta

Rosetta is a Django application that eases the translation process of your Django projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ROSETTA_SHOW_AT_ADMIN_PANEL restricted to users that have access to translation

davtoh opened this issue · comments

  • Which version of Django are you using?: 2.0.6
  • Which version of django-rosetta are you using?: 0.8.1
  • Have you looked trough recent issues and checked this isn't a duplicate? Yes, there are old issues

Hi, a newcommer here. I god a suggestion. I noticed that the ROSSETA submenu will appear regardless if the user can access the admin panel but doesn't have permissions to enter the translation page (resulting in a 404 state code).

Maybe it could be a good Idea to get the user permission in the themplate in rosetta/admin_index.html
like so
https://stackoverflow.com/a/9479717/5288758
{% if perms.app_label.can_do_something %}

{% endif %} and only allow the ROSSETA panel to appear if the user has permissions.

Thank you, hope this helps and contributes to this wonderful app

Rosetta doesn't rely on Django's permission system, but I suppose we could use a template_tag in the overridden admin template to assert whether the current user is allowed to access Rosetta or not.

That seems a nice and strightforward solution. Thank you very much @mbi for attending to it

Reopening because we should rather handle this in Rosetta, than in client code.

If you manage to do it on your end, a pull-request would be most welcome! 😄