Пример #1
0
async def date_time_attribute(session: AsyncSession):
    adal = AsyncDal(session)
    attribute = adal.add(
        Attribute,
        slug="release-date-time",
        name="Release date time",
        type=Attribute.Type.PRODUCT,
        input_type=Attribute.InputType.DATE_TIME,
        filterable_in_storefront=True,
        filterable_in_dashboard=True,
        available_in_grid=True,
    )

    for value in [
            datetime.datetime(2020, 10, 5),
            datetime.datetime(2020, 11, 5),
    ]:
        adal.add(
            AttributeValue,
            attribute=attribute,
            name=f"{attribute.name}: {value.date()}",
            slug=f"{value.date()}_{attribute.id}",
            value=f"{value.date()}",
        )
    await adal.commit()

    return attribute
Пример #2
0
async def size_attribute(session: AsyncSession):
    adal = AsyncDal(session)
    attribute = adal.add(
        Attribute,
        slug="size",
        name="Size",
        type=Attribute.Type.PRODUCT,
        input_type=Attribute.InputType.DROPDOWN,
        filterable_in_storefront=True,
        filterable_in_dashboard=True,
        available_in_grid=True,
    )
    adal.add(AttributeValue,
             attribute=attribute,
             name="3XL",
             slug="3xl",
             value="3xl")
    adal.add(AttributeValue,
             attribute=attribute,
             name="2XL",
             slug="2xl",
             value="2xl")
    adal.add(AttributeValue,
             attribute=attribute,
             name="XL",
             slug="xl",
             value="xl")
    adal.add(AttributeValue,
             attribute=attribute,
             name="L",
             slug="l",
             value="l")
    await adal.commit()
    return attribute
Пример #3
0
async def staff(session: AsyncSession):
    adal = AsyncDal(session)
    ins = adal.add(
        Staff,
        name="admin",
    )
    await adal.commit()
    return ins
Пример #4
0
async def user(session: AsyncSession):
    adal = AsyncDal(session)
    ins = adal.add(
        User,
        email="*****@*****.**",
        is_active=True,
        password="******",
        last_login_at=datetime.datetime.now(),
        first_name="alpha",
        last_name="go",
    )
    await adal.commit()
    return ins
Пример #5
0
async def product_type(session: AsyncSession, color_attribute, size_attribute):
    adal = AsyncDal(session)
    product_type = adal.add(
        ProductType,
        name="Default Type",
        slug="default-type",
        has_variants=True,
        is_shipping_required=True,
        weight=0.1,
        is_digital=True,
    )
    adal.add(
        AttributeProduct,
        attribute=color_attribute,
        product_type=product_type,
    )
    adal.add(
        AttributeProduct,
        attribute=size_attribute,
        product_type=product_type,
    )
    await adal.commit()
    return product_type
Пример #6
0
async def color_attribute(session: AsyncSession):
    adal = AsyncDal(session)
    attribute = adal.add(
        Attribute,
        slug="color",
        name="Color",
        type=Attribute.Type.PRODUCT,
        input_type=Attribute.InputType.DROPDOWN,
        filterable_in_storefront=True,
        filterable_in_dashboard=True,
        available_in_grid=True,
    )
    adal.add(AttributeValue,
             attribute=attribute,
             name="Red",
             slug="red",
             value="red")
    adal.add(AttributeValue,
             attribute=attribute,
             name="Blue",
             slug="blue",
             value="blue")
    await adal.commit()
    return attribute