Various tweaks to products grid filters etc.
Trying to troubleshoot some things...think we're good now. Some of the changes here were made and then discovered not to be necessary yet, but left in place since they're probably good ideas anyway.
This commit is contained in:
		
							parent
							
								
									583548cad5
								
							
						
					
					
						commit
						a5080b113d
					
				
					 5 changed files with 30 additions and 7 deletions
				
			
		|  | @ -43,15 +43,33 @@ from pyramid import httpexceptions | |||
| from pyramid.renderers import render_to_response | ||||
| from webhelpers.html import tags | ||||
| 
 | ||||
| from tailbone import forms | ||||
| from tailbone import forms, newgrids as grids | ||||
| from tailbone.db import Session | ||||
| from tailbone.views import MasterView, SearchableAlchemyGridView, AutocompleteView | ||||
| from tailbone.views.continuum import VersionView, version_defaults | ||||
| from tailbone.forms.renderers import products as products_forms | ||||
| from tailbone.newgrids import GridAction | ||||
| from tailbone.progress import SessionProgress | ||||
| 
 | ||||
| 
 | ||||
| # TODO: For a moment I thought this was going to be necessary, but now I think | ||||
| # not.  Leaving it around for a bit just in case... | ||||
| 
 | ||||
| # class VendorAnyFilter(grids.filters.AlchemyStringFilter): | ||||
| #     """ | ||||
| #     Custom filter for "vendor (any)" so we can avoid joining on that unless we | ||||
| #     really have to.  This is because it seems to throw off the number of | ||||
| #     records which are showed in the result set, when this filter is included in | ||||
| #     the active set but no criteria is specified. | ||||
| #     """ | ||||
| 
 | ||||
| #     def filter(self, query, **kwargs): | ||||
| #         original = query | ||||
| #         query = super(VendorAnyFilter, self).filter(query, **kwargs) | ||||
| #         if query is not original: | ||||
| #             query = self.joiner(query) | ||||
| #         return query | ||||
| 
 | ||||
| 
 | ||||
| class ProductsView(MasterView): | ||||
|     """ | ||||
|     Master view for the Product class. | ||||
|  | @ -122,9 +140,9 @@ class ProductsView(MasterView): | |||
|                                                            model.ProductPrice.uuid == model.Product.regular_price_uuid) | ||||
|         g.joiners['current_price'] = lambda q: q.outerjoin(model.ProductPrice, | ||||
|                                                            model.ProductPrice.uuid == model.Product.current_price_uuid) | ||||
|         g.joiners['code'] = lambda q: q.outerjoin(model.ProductCode) | ||||
|         g.joiners['vendor'] = join_vendor | ||||
|         g.joiners['vendor_any'] = join_vendor_any | ||||
|         g.joiners['code'] = lambda q: q.outerjoin(model.ProductCode) | ||||
| 
 | ||||
|         g.sorters['brand'] = g.make_sorter(model.Brand.name) | ||||
|         g.sorters['department'] = g.make_sorter(model.Department.name) | ||||
|  | @ -143,9 +161,10 @@ class ProductsView(MasterView): | |||
|                                                 default_active=True, default_verb='contains') | ||||
|         g.filters['subdepartment'] = g.make_filter('subdepartment', model.Subdepartment.name) | ||||
|         g.filters['report_code'] = g.make_filter('report_code', model.ReportCode.name) | ||||
|         g.filters['code'] = g.make_filter('code', model.ProductCode.code) | ||||
|         g.filters['vendor'] = g.make_filter('vendor', model.Vendor.name, label="Vendor (preferred)") | ||||
|         g.filters['vendor_any'] = g.make_filter('vendor_any', self.VendorAny.name, label="Vendor (any)") | ||||
|         g.filters['code'] = g.make_filter('code', model.ProductCode.code) | ||||
|                                                 # factory=VendorAnyFilter, joiner=join_vendor_any) | ||||
| 
 | ||||
|         g.default_sortkey = 'description' | ||||
| 
 | ||||
|  | @ -167,7 +186,7 @@ class ProductsView(MasterView): | |||
| 
 | ||||
|         # TODO: need to check for 'print labels' permission here also | ||||
|         if self.print_labels: | ||||
|             g.more_actions.append(GridAction('print_label', icon='print')) | ||||
|             g.more_actions.append(grids.GridAction('print_label', icon='print')) | ||||
| 
 | ||||
|     def template_kwargs_index(self, **kwargs): | ||||
|         if self.print_labels: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar