feat: Added recipe list command
This commit is contained in:
@@ -17,14 +17,3 @@ class Product(Schema):
|
||||
obj[attr] = value
|
||||
return obj
|
||||
|
||||
#id:str = ''
|
||||
#location_id:str = ''
|
||||
#name:str = ''
|
||||
#description:str = ''
|
||||
#qu_id_purchase:str = ''
|
||||
#qu_id_stock:str = ''
|
||||
#qu_factor_purchase_to_stock:float = 0
|
||||
#barcode:str = ''
|
||||
#min_stock_amount:int = 0
|
||||
#default_best_before_days:int = 0
|
||||
#default_best_before_days_after_open:int = 0
|
||||
|
@@ -101,6 +101,17 @@ class Recipe(Schema):
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
def addIngredient(self, ingredient):
|
||||
ingredient['recipe_id'] = self.id
|
||||
hasProduct = False
|
||||
if 'product_id' in ingredient and ingredient['product_id'] is not None:
|
||||
hasProduct = Product.exists(ingredient['product_id'])
|
||||
if hasProduct:
|
||||
self.rest_service.post('recipes_pos', ingredient)
|
||||
else
|
||||
raise Exception('No product was given')
|
||||
|
||||
|
||||
def create(self):
|
||||
created_recipe = {
|
||||
'description': self.description,
|
||||
@@ -110,6 +121,7 @@ class Recipe(Schema):
|
||||
'not_check_shoppinglist': self.not_check_shoppinglist
|
||||
}
|
||||
self.rest_service.post('recipes', created_recipe)
|
||||
|
||||
def get(self, include_products=False):
|
||||
try:
|
||||
recipe = self.rest_service.get('recipes', id=self.id)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
from grocy import RestService
|
||||
import logging
|
||||
|
||||
class Schema(object):
|
||||
|
||||
class Schema(object):
|
||||
def _init_rest_service(self):
|
||||
if hasattr(self, 'api'):
|
||||
if self.api.startswith == '/':
|
||||
|
Reference in New Issue
Block a user