Bind batch to its execution options schema, when applicable
so the batch can provide default values, etc. this also tweaks logic for using defaults from session storage, so that they don't take priority over batch values
This commit is contained in:
		
							parent
							
								
									d75fe88c44
								
							
						
					
					
						commit
						2a2ff721c1
					
				
					 1 changed files with 10 additions and 6 deletions
				
			
		|  | @ -603,8 +603,8 @@ class BatchMasterView(MasterView): | |||
|     # TODO | ||||
|     execution_options_schema = None | ||||
| 
 | ||||
|     def make_execute_schema(self): | ||||
|         return self.execution_options_schema() | ||||
|     def make_execute_schema(self, batch): | ||||
|         return self.execution_options_schema().bind(batch=batch) | ||||
| 
 | ||||
|     def make_execute_form(self, batch=None, **kwargs): | ||||
|         """ | ||||
|  | @ -616,11 +616,15 @@ class BatchMasterView(MasterView): | |||
|         if self.has_execution_options(batch): | ||||
|             if batch is None: | ||||
|                 batch = self.model_class | ||||
|             schema = self.make_execute_schema() | ||||
|             schema = self.make_execute_schema(batch) | ||||
|             for field in schema: | ||||
|                 key = 'batch.{}.execute_option.{}'.format(batch.batch_key, field.name) | ||||
|                 if key in self.request.session: | ||||
|                     defaults[field.name] = self.request.session[key] | ||||
| 
 | ||||
|                 # if field does not yet have a default, maybe provide one from session storage | ||||
|                 if field.default is colander.null: | ||||
|                     key = 'batch.{}.execute_option.{}'.format(batch.batch_key, field.name) | ||||
|                     if key in self.request.session: | ||||
|                         defaults[field.name] = self.request.session[key] | ||||
| 
 | ||||
|         else: | ||||
|             schema = colander.Schema() | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar