diff --git a/tasks.py b/tasks.py index 39bd16a459..2ca62f074d 100644 --- a/tasks.py +++ b/tasks.py @@ -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) - # Clear out any permissions specified for a user - if entry['model'] == 'auth.user': - entry['fields']['user_permissions'] = [] + # 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'] = [] + + 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')