mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55: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: |     with open(tmpfile, 'r') as f_in: | ||||||
|         data = json.loads(f_in.read()) |         data = json.loads(f_in.read()) | ||||||
|  |  | ||||||
|  |     data_out = [] | ||||||
|  |  | ||||||
|     if include_permissions is False: |     if include_permissions is False: | ||||||
|         for entry in data: |         for entry in data: | ||||||
|             if 'model' in entry: |             model_name = entry.get('model', None) | ||||||
|                 # Clear out any permissions specified for a group |  | ||||||
|                 if entry['model'] == 'auth.group': |             # 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'] = [] |                 entry['fields']['permissions'] = [] | ||||||
|  |  | ||||||
|                 # Clear out any permissions specified for a user |             if model_name == 'auth.user': | ||||||
|                 if entry['model'] == 'auth.user': |  | ||||||
|                 entry['fields']['user_permissions'] = [] |                 entry['fields']['user_permissions'] = [] | ||||||
|  |  | ||||||
|  |             data_out.append(entry) | ||||||
|  |  | ||||||
|     # Write the processed data to file |     # Write the processed data to file | ||||||
|     with open(filename, 'w') as f_out: |     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') |     print('Data export completed') | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user