#30289 closed Bug (fixed)
Admin inlines for auto-created ManyToManyFields are editable if the user only has the view permission
| Reported by: | Jayen Ashar | Owned by: | Tim Graham |
|---|---|---|---|
| Component: | contrib.admin | Version: | 2.1 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
From https://code.djangoproject.com/ticket/8060#comment:34
Replying to Will Gordon:
This seems to have regressed in (at least) 2.1. I have 2
viewonly permissions. I have aManyToManyFieldrepresented in my main model as aTabularInline. But, my user withviewonly permissions can now add or remove these items at will!
I am having the same issue, so I assume this is a bug. I did not find Will had created a separate ticket.
models.py:
class Photo(models.Model):
pass
class Report(models.Model):
photos = models.ManyToManyField(Photo)
admin.py:
class ReportPhotoInlineModelAdmin(admin.TabularInline):
model = Report.photos.through
show_change_link = True
Attachments (1)
Change History (9)
comment:1 by , 7 years ago
| Severity: | Normal → Release blocker |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
by , 7 years ago
| Attachment: | ticket_30289.zip added |
|---|
Zip with sample project. load fixture.json to populate database Username: readonly Password:1234567890abc
comment:2 by , 7 years ago
Sample project attached: migrate db; load fixture.json. Log in to admin as readonly with password 1234567890abc.
Navigate to Issue > Report admin. You can adjust the M2M. You shouldn't be able to.
comment:3 by , 7 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Summary: | ManyToManyField Admin Inlines do not respect user permissions → Admin inlines for auto-created ManyToManyFields are editable if the user only has the view permission |
comment:5 by , 7 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
OK, yes. Fleshing it out I can reproduce this against 2.1.7 with the models and inline provided.
A user with only the view permission for both Report and Photo can edit the M2M in the inline.
When the M2M is handled as a normal field, rather than an inline, the behaviour is correct.
Elevating to a Release Blocker as a regression and/or a bug in the new view permissions feature.