integreat-cms icon indicating copy to clipboard operation
integreat-cms copied to clipboard

Manage permission in fixture again instead of migrations

Open timobrembeck opened this issue 2 years ago • 1 comments

Motivation

In the early stages of this project, we stored the permission in a fixture which we could just update by running integreat-cms-cli loadddata roles.

The main problem with this approach was that we referenced permissions by ids, and on the dev systems the ids of the permissions changed each time the database was reset after a model change. Thus, I suggested the current mechanism of managing roles via migrations (see #748).

However, I wasn't aware at the time that the readable (and constant) permission names could also be used as keys in the fixture instead of the numeric ids. Considering the current overhead of having to change the constants and then generate a migration which applies the changed constants, I think the previous approach wasn't too bad if we change the way we reference the permissions.

Proposed Solution

  • Create a fixture integreat_cms/cms/fixtures/permissions.json
  • Convert the current definitions from integreat_cms/cms/constants/roles.py to json and put it into the new file
  • Remove all permissions from roles.py (but keep the role definitions)
  • Squash the migrations to get rid of all the role-changing migrations and speed up the setup of new systems and the tests (which need to run the migrations before each test run)
  • Add the step integreat-cms-cli loadddata permissions to the run.sh script
  • Add the step integreat-cms-cli loadddata permissions to the deploy script on salt

Alternatives

Just keep the current setup

timobrembeck avatar Nov 11 '22 19:11 timobrembeck