feat: Added recipe list command

This commit is contained in:
Aerex
2019-06-16 23:54:10 -05:00
parent a1c593b118
commit 0a1ecddf3d
14 changed files with 472 additions and 96 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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 == '/':