Beispiel #1
0
 def __init__(self,
              session=None,
              name=None,
              slug=None,
              position=0,
              categories=[],
              **_) -> None:
     self.name = name
     self.slug = slug
     self.position = position
     self.categories = [
         Category.get_ref(session=session, slug=cat.get("slug"))
         for cat in categories
     ]
Beispiel #2
0
 def __init__(
     self,
     session: Session = None,
     language="en",
     categories: list = [],
     show_recent=True,
     cards_per_section: int = 9,
 ) -> None:
     session.commit()
     self.language = language
     self.cards_per_section = cards_per_section
     self.show_recent = show_recent
     self.categories = [
         Category.get_ref(session=session, slug=cat.get("slug"))
         for cat in categories
     ]
Beispiel #3
0
    def __init__(self,
                 name,
                 categories=[],
                 session=None,
                 webhook_enable=False,
                 webhook_time="00:00",
                 webhook_urls=[],
                 **_) -> None:
        self.name = name
        self.categories = [
            Category.get_ref(session=session, slug=cat.get("slug"))
            for cat in categories
        ]

        self.webhook_enable = webhook_enable
        self.webhook_time = webhook_time
        self.webhook_urls = [WebhookURLModel(url=x) for x in webhook_urls]
Beispiel #4
0
    def __init__(self,
                 session,
                 name: str = None,
                 description: str = None,
                 image: str = None,
                 recipe_yield: str = None,
                 recipe_ingredient: list[str] = None,
                 recipe_instructions: list[dict] = None,
                 recipeCuisine: str = None,
                 total_time: str = None,
                 prep_time: str = None,
                 cook_time: str = None,
                 nutrition: dict = None,
                 tools: list[str] = None,
                 perform_time: str = None,
                 slug: str = None,
                 recipe_category: list[str] = None,
                 tags: list[str] = None,
                 date_added: datetime.date = None,
                 notes: list[dict] = None,
                 rating: int = None,
                 org_url: str = None,
                 extras: dict = None,
                 assets: list = None,
                 settings: dict = None,
                 **_) -> None:
        self.name = name
        self.description = description
        self.image = image
        self.recipeCuisine = recipeCuisine

        self.nutrition = Nutrition(
            **nutrition) if self.nutrition else Nutrition()

        self.tools = [Tool(tool=x) for x in tools] if tools else []

        self.recipe_yield = recipe_yield
        self.recipe_ingredient = [
            RecipeIngredient(**ingr, session=session)
            for ingr in recipe_ingredient
        ]
        self.assets = [RecipeAsset(**a) for a in assets]
        self.recipe_instructions = [
            RecipeInstruction(text=instruc.get("text"),
                              title=instruc.get("title"),
                              type=instruc.get("@type", None))
            for instruc in recipe_instructions
        ]
        self.total_time = total_time
        self.prep_time = prep_time
        self.perform_time = perform_time
        self.cook_time = cook_time

        self.recipe_category = [
            Category.create_if_not_exist(session=session, name=cat)
            for cat in recipe_category
        ]

        # Mealie Specific
        self.settings = RecipeSettings(
            **settings) if settings else RecipeSettings()
        self.tags = [
            Tag.create_if_not_exist(session=session, name=tag) for tag in tags
        ]
        self.slug = slug
        self.notes = [Note(**note) for note in notes]
        self.rating = rating
        self.org_url = org_url
        self.extras = [
            ApiExtras(key=key, value=value) for key, value in extras.items()
        ]

        # Time Stampes
        self.date_added = date_added
        self.date_updated = datetime.datetime.now()
Beispiel #5
0
    def __init__(
        self,
        session,
        name: str = None,
        description: str = None,
        image: str = None,
        recipeYield: str = None,
        recipeIngredient: List[str] = None,
        recipeInstructions: List[dict] = None,
        recipeCuisine: str = None,
        totalTime: str = None,
        prepTime: str = None,
        nutrition: dict = None,
        tools: list[str] = [],
        performTime: str = None,
        slug: str = None,
        recipeCategory: List[str] = None,
        tags: List[str] = None,
        dateAdded: datetime.date = None,
        notes: List[dict] = None,
        rating: int = None,
        orgURL: str = None,
        extras: dict = None,
    ) -> None:
        self.name = name
        self.description = description
        self.image = image
        self.recipeCuisine = recipeCuisine

        self.nutrition = Nutrition(
            **nutrition) if self.nutrition else Nutrition()
        self.tools = [Tool(tool=x) for x in tools] if tools else []

        self.recipeYield = recipeYield
        self.recipeIngredient = [
            RecipeIngredient(ingredient=ingr) for ingr in recipeIngredient
        ]
        self.recipeInstructions = [
            RecipeInstruction(text=instruc.get("text"),
                              type=instruc.get("@type", None))
            for instruc in recipeInstructions
        ]
        self.totalTime = totalTime
        self.prepTime = prepTime
        self.performTime = performTime

        self.recipeCategory = [
            Category.create_if_not_exist(session=session, name=cat)
            for cat in recipeCategory
        ]

        # Mealie Specific
        self.tags = [
            Tag.create_if_not_exist(session=session, name=tag) for tag in tags
        ]
        self.slug = slug
        self.dateAdded = dateAdded
        self.notes = [Note(**note) for note in notes]
        self.rating = rating
        self.orgURL = orgURL
        self.extras = [
            ApiExtras(key=key, value=value) for key, value in extras.items()
        ]