class Test(JsonObject): id = fields.Int() name = fields.Str() quantity = fields.Float() email = fields.Email() date = fields.DateTime( format='%Y-%m-%d %H:%M', missing=lambda: datetime.now().strftime('%Y-%m-%d %H:%M')) class Meta: ordered = True
class Ingredient(JsonObject): id = fields.Int() name = fields.Str() calories = fields.Float() sugar = fields.Float() veg_protein = fields.Float() protein = fields.Float() carbo = fields.Float() fats = fields.Float() class Meta: ordered = True def columns(): return Ingredient.fields()
class Meal(JsonObject): id = fields.Int() name = fields.Str() date = fields.DateTime( format='%Y-%m-%d %H:%M', default=lambda: datetime.now().strftime('%Y-%m-%d %H:%M')) meal_ingredients = fields.List(fields.Nested(MealIngredient), missing=[]) class Meta: ordered = True def columns(): return [x for x in Meal.fields() if x not in ('meal_ingredients',)]
class ParamsHolder(JsonObject): params = fields.List(fields.Str(), missing=[])
class Due(JsonObject): id = fields.Int() name = fields.Str() unos = fields.List(fields.Nested(Uno))
class Uno(JsonObject): name = fields.Str() date = fields.DateTime(format='%Y-%m-%d %H:%M')