diff --git a/CHANGELOG.md b/CHANGELOG.md index edfcf92..956fb6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ We follow [Semantic Versions](https://semver.org/). - Replace [httpx](https://github.com/encode/httpx) with [httpx2](https://github.com/pydantic/httpx2) in docs and tests +- Improve docs for get params Django API ## 0.8.0 diff --git a/pyproject.toml b/pyproject.toml index 923aa0f..0f16276 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,6 +108,10 @@ local = [ # A library and CLI app for rendering project templates. # https://copier.readthedocs.io/en/latest/ "copier", + # Werkzeug is a comprehensive WSGI web application library. + # Required to use runserver_plus + # https://werkzeug.palletsprojects.com/en/stable/ + "Werkzeug", ] linters = [ # Mypy is a static type checker for Python. diff --git a/saritasa_s3_tools/configs.py b/saritasa_s3_tools/configs.py index bd2de58..f4605fd 100644 --- a/saritasa_s3_tools/configs.py +++ b/saritasa_s3_tools/configs.py @@ -39,6 +39,25 @@ class S3FileTypeConfig(metaclass=S3FileTypeConfigMeta): expires_in: int = 3600 success_action_status: int = 201 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition - content_disposition: ( - typing.Literal["attachment"] | typing.Literal["inline"] - ) = "attachment" + content_disposition: typing.Literal["attachment", "inline"] = "attachment" + + def get_short_description(self) -> str: + """Get short description for config.""" + allowed_types = ( + ", ".join(self.allowed) if self.allowed else "All types" + ) + content_length_range = ( + ( + f"{self.content_length_range[0]}-" + f"{self.content_length_range[1]} bytes" + ) + if self.content_length_range + else "Any length" + ) + return ( + f"*Allowed types*: {allowed_types}, " + f"*Content length range*: {content_length_range}, " + f"*Expires in*: {self.expires_in} seconds, " + f"*Success action status*: {self.success_action_status}, " + f"*Content disposition*: {self.content_disposition}" + ) diff --git a/saritasa_s3_tools/django/drf_fields.py b/saritasa_s3_tools/django/drf_fields.py index 289b660..ced0d84 100644 --- a/saritasa_s3_tools/django/drf_fields.py +++ b/saritasa_s3_tools/django/drf_fields.py @@ -25,7 +25,9 @@ def _get_choices(self) -> dict[str, str]: current_choices = tuple( ( config_name, - config_name, + configs.S3FileTypeConfig.configs[ + config_name + ].get_short_description(), ) for config_name in configs.S3FileTypeConfig.configs ) diff --git a/uv.lock b/uv.lock index 3e1b6ab..f17cbe7 100644 --- a/uv.lock +++ b/uv.lock @@ -1884,6 +1884,7 @@ local = [ { name = "ipython" }, { name = "prek" }, { name = "saritasa-invocations", extra = ["env-settings"] }, + { name = "werkzeug" }, ] test = [ { name = "coverage" }, @@ -1935,6 +1936,7 @@ local = [ { name = "ipython" }, { name = "prek" }, { name = "saritasa-invocations", extras = ["env-settings"] }, + { name = "werkzeug" }, ] test = [ { name = "coverage" }, @@ -2113,3 +2115,15 @@ sdist = { url = "https://files.pythonhosted.org/packages/34/74/c6428f875774288be wheels = [ { url = "https://files.pythonhosted.org/packages/96/42/3e5985a0a7e57de470b320c6d6a1a67c844f6737a587f3d44dd13d1819e7/wcwidth-0.8.2-py3-none-any.whl", hash = "sha256:d63947694a0539a1d51e01eda7caf800c291020e6cdd7e28ad7b14dd33ad4f85", size = 323166, upload-time = "2026-06-29T18:11:09.888Z" }, ] + +[[package]] +name = "werkzeug" +version = "3.1.8" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/dd/b2/381be8cfdee792dd117872481b6e378f85c957dd7c5bca38897b08f765fd/werkzeug-3.1.8.tar.gz", hash = "sha256:9bad61a4268dac112f1c5cd4630a56ede601b6ed420300677a869083d70a4c44", size = 875852, upload-time = "2026-04-02T18:49:14.268Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/93/8c/2e650f2afeb7ee576912636c23ddb621c91ac6a98e66dc8d29c3c69446e1/werkzeug-3.1.8-py3-none-any.whl", hash = "sha256:63a77fb8892bf28ebc3178683445222aa500e48ebad5ec77b0ad80f8726b1f50", size = 226459, upload-time = "2026-04-02T18:49:12.72Z" }, +]