Expose label profile selection when editing label batch
This commit is contained in:
		
							parent
							
								
									a637ba1e6b
								
							
						
					
					
						commit
						5151e2dd96
					
				
					 1 changed files with 16 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -30,6 +30,7 @@ import six
 | 
			
		|||
 | 
			
		||||
from rattail.db import model
 | 
			
		||||
 | 
			
		||||
from deform import widget as dfwidget
 | 
			
		||||
from webhelpers2.html import HTML, tags
 | 
			
		||||
 | 
			
		||||
from tailbone import forms
 | 
			
		||||
| 
						 | 
				
			
			@ -70,6 +71,7 @@ class LabelBatchView(BatchMasterView):
 | 
			
		|||
        'id',
 | 
			
		||||
        'description',
 | 
			
		||||
        'static_prices',
 | 
			
		||||
        'label_profile',
 | 
			
		||||
        'notes',
 | 
			
		||||
        'created',
 | 
			
		||||
        'created_by',
 | 
			
		||||
| 
						 | 
				
			
			@ -116,12 +118,25 @@ class LabelBatchView(BatchMasterView):
 | 
			
		|||
        # handheld_batches
 | 
			
		||||
        f.set_readonly('handheld_batches')
 | 
			
		||||
        f.set_renderer('handheld_batches', self.render_handheld_batches)
 | 
			
		||||
 | 
			
		||||
        if self.viewing or self.deleting:
 | 
			
		||||
            batch = self.get_instance()
 | 
			
		||||
            if not batch._handhelds:
 | 
			
		||||
                f.remove_field('handheld_batches')
 | 
			
		||||
 | 
			
		||||
        # label profile
 | 
			
		||||
        if self.creating or self.editing:
 | 
			
		||||
            if 'label_profile' in f.fields:
 | 
			
		||||
                f.replace('label_profile', 'label_profile_uuid')
 | 
			
		||||
                # TODO: should restrict somehow? just allow override?
 | 
			
		||||
                profiles = self.Session.query(model.LabelProfile)
 | 
			
		||||
                values = [(p.uuid, six.text_type(p))
 | 
			
		||||
                          for p in profiles]
 | 
			
		||||
                require_profile = False
 | 
			
		||||
                if not require_profile:
 | 
			
		||||
                    values.insert(0, ('', "(none)"))
 | 
			
		||||
                f.set_widget('label_profile_uuid', dfwidget.SelectWidget(values=values))
 | 
			
		||||
                f.set_label('label_profile_uuid', "Label Profile")
 | 
			
		||||
 | 
			
		||||
    def render_handheld_batches(self, label_batch, field):
 | 
			
		||||
        items = ''
 | 
			
		||||
        for handheld in label_batch._handhelds:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue