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
32 lines
990 B
Python
32 lines
990 B
Python
from api.v1.user import schemas
|
|
from apps.promo.models import Promocode
|
|
from apps.user.models import User
|
|
|
|
|
|
def map_user_to_schema(user: User) -> schemas.ViewUserOut:
|
|
return schemas.ViewUserOut(
|
|
name=user.name,
|
|
surname=user.surname,
|
|
email=user.email,
|
|
avatar_url=user.avatar_url,
|
|
other=schemas.UserTarget(
|
|
age=user.age,
|
|
country=user.country_raw,
|
|
),
|
|
)
|
|
|
|
|
|
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,
|
|
is_activated_by_user=promocode.is_activated_by_user,
|
|
is_liked_by_user=promocode.is_liked_by_user,
|
|
like_count=promocode.like_count,
|
|
comment_count=promocode.comment_count,
|
|
active=promocode.active,
|
|
)
|