Add fixture for users / groups

This commit is contained in:
Oliver Walters 2021-04-25 11:41:48 +10:00
parent e13850515d
commit f766711838
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,53 @@
- model: auth.group
pk: 1
fields:
name: "Viewers"
- model: auth.group
pk: 2
fields:
name: "Engineers"
- model: auth.group
pk: 3
fields:
name: "Sales"
- model: auth.user
pk: 1
fields:
username: "sue_the_superuser"
is_superuser: true
- model: auth.user
pk: 2
fields:
username: "engineer_eddie"
groups:
- 2
is_active: true
is_staff: false
is_superuser: false
- model: auth.user
pk: 3
fields:
username: "alanallgroup"
first_name: "Alan"
last_name: "Allgroup"
is_active: false
groups:
- 1
- 2
- 3
- model: auth.user
pk: 4
fields:
username: "sam"
first_name: "Samuel"
last_name: "Salesperson"
groups:
- 3
is_staff: true
is_superuser: true

View File

@ -286,6 +286,8 @@ def export_records(c, filename='data.json'):
# Dump data to temporary file
manage(c, cmd, pty=True)
print("Running data post-processing step...")
# Post-process the file, to remove any "permissions" specified for a group
with open(tmpfile, "r") as f_in:
data = json.loads(f_in.read())
@ -365,6 +367,9 @@ def import_fixtures(c):
'location',
'stock_tests',
'stock',
# Users
'users'
]
command = 'loaddata ' + ' '.join(fixtures)