Add products API route to fetch label profiles for use w/ printing
This commit is contained in:
parent
de373a683b
commit
75caface6b
2 changed files with 29 additions and 7 deletions
|
@ -125,6 +125,24 @@ class ProductView(APIMasterView):
|
|||
return {'ok': True,
|
||||
'product': self.normalize(product)}
|
||||
|
||||
def label_profiles(self):
|
||||
"""
|
||||
Returns the set of label profiles available for use with
|
||||
printing label for product.
|
||||
"""
|
||||
app = self.get_rattail_app()
|
||||
label_handler = app.get_label_handler()
|
||||
model = self.model
|
||||
|
||||
profiles = []
|
||||
for profile in label_handler.get_label_profiles(self.Session()):
|
||||
profiles.append({
|
||||
'uuid': profile.uuid,
|
||||
'description': profile.description,
|
||||
})
|
||||
|
||||
return {'label_profiles': profiles}
|
||||
|
||||
def print_labels(self):
|
||||
app = self.get_rattail_app()
|
||||
label_handler = app.get_label_handler()
|
||||
|
@ -176,6 +194,13 @@ class ProductView(APIMasterView):
|
|||
permission='{}.list'.format(permission_prefix))
|
||||
config.add_cornice_service(quick_lookup)
|
||||
|
||||
# label profiles
|
||||
label_profiles = Service(name=f'{route_prefix}.label_profiles',
|
||||
path=f'{collection_url_prefix}/label-profiles')
|
||||
label_profiles.add_view('GET', 'label_profiles', klass=cls,
|
||||
permission=f'{permission_prefix}.print_labels')
|
||||
config.add_cornice_service(label_profiles)
|
||||
|
||||
# print labels
|
||||
print_labels = Service(name='{}.print_labels'.format(route_prefix),
|
||||
path='{}/print-labels'.format(collection_url_prefix))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue