# -*- 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(), })