mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	Update tasks.py (#6446)
* Update tasks.py - Exclude temporary settings when exporting data * Remove duplicate code
This commit is contained in:
		
							
								
								
									
										20
									
								
								tasks.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								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': | ||||
|             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'] = [] | ||||
|  | ||||
|                 # Clear out any permissions specified for a user | ||||
|                 if entry['model'] == 'auth.user': | ||||
|             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') | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user