Refactor Query.get()
=> Session.get()
per SQLAlchemy 1.4
This commit is contained in:
parent
81aa0ae109
commit
f611a5a521
38 changed files with 169 additions and 205 deletions
|
@ -808,10 +808,10 @@ class ProductView(MasterView):
|
|||
|
||||
def get_instance(self):
|
||||
key = self.request.matchdict['uuid']
|
||||
product = self.Session.query(model.Product).get(key)
|
||||
product = self.Session.get(model.Product, key)
|
||||
if product:
|
||||
return product
|
||||
price = self.Session.query(model.ProductPrice).get(key)
|
||||
price = self.Session.get(model.ProductPrice, key)
|
||||
if price:
|
||||
return price.product
|
||||
raise self.notfound()
|
||||
|
@ -956,7 +956,7 @@ class ProductView(MasterView):
|
|||
brand_display = ""
|
||||
if self.request.method == 'POST':
|
||||
if self.request.POST.get('brand_uuid'):
|
||||
brand = self.Session.query(model.Brand).get(self.request.POST['brand_uuid'])
|
||||
brand = self.Session.get(model.Brand, self.request.POST['brand_uuid'])
|
||||
if brand:
|
||||
brand_display = str(brand)
|
||||
elif self.editing:
|
||||
|
@ -1751,12 +1751,12 @@ class ProductView(MasterView):
|
|||
model = self.model
|
||||
|
||||
profile = self.request.params.get('profile')
|
||||
profile = self.Session.query(model.LabelProfile).get(profile) if profile else None
|
||||
profile = self.Session.get(model.LabelProfile, profile) if profile else None
|
||||
if not profile:
|
||||
return {'error': "Label profile not found"}
|
||||
|
||||
product = self.request.params.get('product')
|
||||
product = self.Session.query(model.Product).get(product) if product else None
|
||||
product = self.Session.get(model.Product, product) if product else None
|
||||
if not product:
|
||||
return {'error': "Product not found"}
|
||||
|
||||
|
@ -1901,7 +1901,7 @@ class ProductView(MasterView):
|
|||
}
|
||||
uuid = self.request.GET.get('with_vendor_cost')
|
||||
if uuid:
|
||||
vendor = self.Session.query(model.Vendor).get(uuid)
|
||||
vendor = self.Session.get(model.Vendor, uuid)
|
||||
if not vendor:
|
||||
return {'error': "Vendor not found"}
|
||||
cost = product.cost_for_vendor(vendor)
|
||||
|
@ -2068,7 +2068,7 @@ class ProductView(MasterView):
|
|||
Threat target for making a batch from current products query.
|
||||
"""
|
||||
session = RattailSession()
|
||||
user = session.query(model.User).get(user_uuid)
|
||||
user = session.get(model.User, user_uuid)
|
||||
assert user
|
||||
params['created_by'] = user
|
||||
try:
|
||||
|
@ -2288,7 +2288,7 @@ class PendingProductView(MasterView):
|
|||
brand_display = ""
|
||||
if self.request.method == 'POST':
|
||||
if self.request.POST.get('brand_uuid'):
|
||||
brand = self.Session.query(model.Brand).get(self.request.POST['brand_uuid'])
|
||||
brand = self.Session.get(model.Brand, self.request.POST['brand_uuid'])
|
||||
if brand:
|
||||
brand_display = str(brand)
|
||||
elif self.editing:
|
||||
|
@ -2315,7 +2315,7 @@ class PendingProductView(MasterView):
|
|||
vendor_display = ""
|
||||
if self.request.method == 'POST':
|
||||
if self.request.POST.get('vendor_uuid'):
|
||||
vendor = self.Session.query(model.Vendor).get(self.request.POST['vendor_uuid'])
|
||||
vendor = self.Session.get(model.Vendor, self.request.POST['vendor_uuid'])
|
||||
if vendor:
|
||||
vendor_display = str(vendor)
|
||||
f.set_widget('vendor_uuid', forms.widgets.JQueryAutocompleteWidget(
|
||||
|
@ -2414,7 +2414,7 @@ class PendingProductView(MasterView):
|
|||
redirect = self.redirect(self.get_action_url('view', pending))
|
||||
|
||||
uuid = self.request.POST['product_uuid']
|
||||
product = self.Session.query(model.Product).get(uuid)
|
||||
product = self.Session.get(model.Product, uuid)
|
||||
if not product:
|
||||
self.request.session.flash("Product not found!", 'error')
|
||||
return redirect
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue