You've already forked hotpocket
This commit is contained in:
28
services/backend/hotpocket_backend/apps/ui/dto/base.py
Normal file
28
services/backend/hotpocket_backend/apps/ui/dto/base.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- 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(),
|
||||
})
|
||||
Reference in New Issue
Block a user