Creating a Django group to limit who can create competitions
- Dominant language
- Python
- Stars
- 176
- Forks
- 74
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 21
Description
Hi,
I am trying to create a django group with permissions to create competitions so that users would need to be added to this group by administrators before they can create competitions. I want regular authenticated users to not have the permission to create competitions. I have tried implementing this by creating a new permission class IsCompetitionCreator similar to the existing IsOrganizationEditor permission in src/apps/api/permissions.py. Then I changed this file src/apps/api/views/competitions.py to use: if self.action in ['create']: self.permission_classes = [IsCompetitionCreator], instead of using [IsAuthenticated]. I made sure to restart django and run the migration, however, when I test by creating a new user, I see that they still have permissions to create competitions. I also see on the django site administration, that every user shows the Competition Creator group, but I checked that the group was actually empty. Is there a better way I can go about creating this group, or do you guys have any idea why this method is not working?
Thanks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/apps/api/permissions.py and src/apps/api/views/competitions.py, then reproduce the behavior using an empty Competition Creator group and a newly created user. Check why the create action still permits regular authenticated users and why the group appears assigned in Django administration; done means only users in the intended group can create competitions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, authorization, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100