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

Disable inline sorting when user does not have change permission #186

Open
antoinehumbert opened this issue Aug 8, 2020 · 0 comments
Open

Comments

@antoinehumbert
Copy link

When using sortable inlines, if user has view permission for a model, but not change permission, inlines remain sortable on the user interface.
Of course, the positions changes cannot be saved, but it would be better to disable inlines sorting if user does not have change permission.

Such behaviour can be achieved by modifiying the templates:

  • stacked.html: replace <h3 class="{% if not inline_opts.sortable_options or not inline_opts.sortable_options.disabled %} djn-drag-handler{% endif %}"> by <h3 class="{% if inline_admin_formset.has_change_permission %}{% if not inline_opts.sortable_options or not inline_opts.sortable_options.disabled %} djn-drag-handler{% endif %}{% endif %}">
  • tabular.html: replace {% if inline_admin_formset.opts.sortable_field_name %}<span class="djn-drag-handler"></span>{% endif %} by {% if inline_admin_formset.has_change_permission %}{% if inline_admin_formset.opts.sortable_field_name %}<span class="djn-drag-handler"></span>{% endif %}{% endif %}

grappelli and polymorphic templates may be impacted as well.

Does this sound correct to you ?

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