mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
from marshmallow import fields
|
|
|
|
from project.api import marshmallow
|
|
from project.api.event.schemas import (
|
|
EventRefSchema,
|
|
EventSearchItemSchema,
|
|
EventSearchRequestSchema,
|
|
)
|
|
from project.api.schemas import PaginationRequestSchema, PaginationResponseSchema
|
|
from project.models import EventDate
|
|
|
|
|
|
class EventDateSchema(marshmallow.SQLAlchemySchema):
|
|
class Meta:
|
|
model = EventDate
|
|
load_instance = True
|
|
|
|
id = marshmallow.auto_field()
|
|
start = marshmallow.auto_field()
|
|
end = marshmallow.auto_field()
|
|
event = fields.Nested(EventRefSchema)
|
|
|
|
|
|
class EventDateRefSchema(marshmallow.SQLAlchemySchema):
|
|
class Meta:
|
|
model = EventDate
|
|
load_instance = True
|
|
|
|
id = marshmallow.auto_field()
|
|
start = marshmallow.auto_field()
|
|
|
|
|
|
class EventDateListRequestSchema(PaginationRequestSchema):
|
|
pass
|
|
|
|
|
|
class EventDateListResponseSchema(PaginationResponseSchema):
|
|
items = fields.List(
|
|
fields.Nested(EventDateRefSchema), metadata={"description": "Dates"}
|
|
)
|
|
|
|
|
|
class EventDateSearchRequestSchema(EventSearchRequestSchema):
|
|
pass
|
|
|
|
|
|
class EventDateSearchItemSchema(EventDateRefSchema):
|
|
class Meta:
|
|
model = EventDate
|
|
load_instance = True
|
|
|
|
end = marshmallow.auto_field()
|
|
event = fields.Nested(EventSearchItemSchema)
|
|
|
|
|
|
class EventDateSearchResponseSchema(PaginationResponseSchema):
|
|
items = fields.List(
|
|
fields.Nested(EventDateSearchItemSchema), metadata={"description": "Dates"}
|
|
)
|