You've already forked Promocode-API
mirror of
https://github.com/devitq/Promocode-API.git
synced 2026-05-22 23:17:10 +00:00
b7d7334fe5
also bug fixes and improvements
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from api.v1.business import schemas
|
|
from apps.promo.models import Promocode
|
|
|
|
|
|
def map_promocode_to_schema(promocode: Promocode) -> schemas.PromocodeViewOut:
|
|
return schemas.PromocodeViewOut(
|
|
promo_id=promocode.id,
|
|
company_id=promocode.business.id,
|
|
company_name=promocode.business.name,
|
|
description=promocode.description,
|
|
image_url=promocode.image_url,
|
|
target=schemas.PromocodeTargetViewOut(
|
|
age_from=promocode.target.age_from,
|
|
age_until=promocode.target.age_until,
|
|
country=promocode.target.country_raw
|
|
if promocode.target.country_raw
|
|
else None,
|
|
categories=promocode.target.categories,
|
|
),
|
|
max_count=promocode.max_count,
|
|
active_from=promocode.active_from,
|
|
active_until=promocode.active_until,
|
|
mode=promocode.mode,
|
|
promo_common=promocode.promo_common,
|
|
promo_unique=promocode.promo_unique,
|
|
like_count=promocode.like_count,
|
|
used_count=promocode.used_count,
|
|
active=promocode.active,
|
|
)
|