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

Update tasks.py #6446

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,20 +504,28 @@ def export_records(
with open(tmpfile, 'r') as f_in:
data = json.loads(f_in.read())

data_out = []

if include_permissions is False:
for entry in data:
if 'model' in entry:
# Clear out any permissions specified for a group
if entry['model'] == 'auth.group':
entry['fields']['permissions'] = []
model_name = entry.get('model', None)

# Ignore any temporary settings (start with underscore)
if model_name in ['common.inventreesetting', 'common.inventreeusersetting']:
if entry['fields'].get('key', '').startswith('_'):
continue

if model_name == 'auth.group':
entry['fields']['permissions'] = []

if model_name == 'auth.user':
entry['fields']['user_permissions'] = []

# Clear out any permissions specified for a user
if entry['model'] == 'auth.user':
entry['fields']['user_permissions'] = []
data_out.append(entry)

# Write the processed data to file
with open(filename, 'w') as f_out:
f_out.write(json.dumps(data, indent=2))
f_out.write(json.dumps(data_out, indent=2))

print('Data export completed')

Expand Down
Loading