Example #1
0
class MealIngredient(JsonObject):
    id = fields.Int()
    meal_id = fields.Int()
    ingredient_id = fields.Int()
    quantity = fields.Float()

    ingredient = fields.Nested(Ingredient, missing=None)

    class Meta:
        ordered = True

    def columns():
        return [x for x in MealIngredient.fields() 
            if x not in ('ingredient',)]
Example #2
0
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
Example #3
0
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()
Example #4
0
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',)]
Example #5
0
class Due(JsonObject):
    id = fields.Int()
    name = fields.Str()
    unos = fields.List(fields.Nested(Uno))