hotpocket/services/backend/hotpocket_backend/apps/ui/dto/base.py
Tomek Wójcik b4338e2769
Some checks failed
CI / Checks (push) Failing after 13m2s
Release v1.0.0
2025-08-20 21:00:50 +02:00

29 lines
798 B
Python

# -*- coding: utf-8 -*-
from __future__ import annotations
import typing
import uuid
from django.http import HttpRequest
import pydantic
class BrowseParams(pydantic.BaseModel):
view_name: str
account_uuid: uuid.UUID
search: str | None = pydantic.Field(default=None)
before: uuid.UUID | None = pydantic.Field(default=None)
after: uuid.UUID | None = pydantic.Field(default=None)
limit: int = pydantic.Field(default=10)
@classmethod
def from_request(cls: type[typing.Self],
*,
request: HttpRequest,
) -> typing.Self:
return cls.model_validate({
'view_name': request.resolver_match.url_name,
'account_uuid': request.user.pk,
**request.GET.dict(),
})