Skip to content

Commit

Permalink
Release 0.8.0 (#160)
Browse files Browse the repository at this point in the history
* Dev release for 0.8.0

* Update doc

* Update changelog

* Release 0.8.0
  • Loading branch information
jowilf authored Apr 9, 2023
1 parent 51df7c2 commit a196b5f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
19 changes: 19 additions & 0 deletions docs/changelog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.0] - 2023-04-09

### Added

* Add extension to autovalidate SQLAlchemy data with pydantic by [@jowilf](https://github.com/jowilf)
in [#144](https://github.com/jowilf/starlette-admin/pull/144)
* Make `_extract_fields()` method in BaseModelView public and renamed
to [get_fields_list()][starlette_admin.views.BaseModelView.get_fields_list] by [@jowilf](https://github.com/jowilf)
in [#148](https://github.com/jowilf/starlette-admin/pull/148)
* Add support for custom object representations in the admin interface with `__admin_repr__`
and `__admin_select2_repr__` by [@jowilf](https://github.com/jowilf)
in [#152](https://github.com/jowilf/starlette-admin/pull/152). The documentation can be
found [here](../tutorial/configurations/modelview/#object-representation)

### Internals

* Enhance code quality with additional ruff rules by [@jowilf](https://github.com/jowilf)
in [#159](https://github.com/jowilf/starlette-admin/pull/159)

## [0.7.0] - 2023-03-24

### Added
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 27 additions & 19 deletions docs/tutorial/configurations/modelview/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,22 @@ It is a special method that can be defined in a model class to customize the obj
interface. By default, only the value of the object's primary key attribute is displayed. However, by implementing
`__admin_repr__`, you can return a string that better represents the object in the admin interface.

For example, the following implementation for a `User` model will display the user's full name instead of their primary
key in the admin interface:
!!! Example
For example, the following implementation for a `User` model will display the user's full name instead of their primary
key in the admin interface:

```python
class User:
id: int
first_name: str
last_name: str
```python
class User:
id: int
first_name: str
last_name: str

async def __admin_repr__(self, request: Request):
return f"{self.last_name} {self.first_name}"
```

![Custom Object representation](../../../images/tutorial/configurations/modelview/object_text_representation.png){ width="200" }

def __admin_repr__(self, request: Request):
return f"{self.last_name} {self.first_name}"
```

### `__admin_select2_repr__`

Expand All @@ -183,14 +187,18 @@ fields.
Template("Hello {{name}}", autoescape=True).render(name=name)
```

Here is an example implementation for a `User` model that includes the user's name and photo:
!!! Example

```python
class User:
id: int
name: str
photo_url: str
Here is an example implementation for a `User` model that includes the user's name and photo:

def __admin_select2_repr__(self, request: Request) -> str:
return f'<div><img src="{escape(photo_url)}"><span>{escape(self.name)}</span></div>'
```
```python
class User:
id: int
name: str
photo_url: str

async def __admin_select2_repr__(self, request: Request) -> str:
return f'<div><img src="{escape(photo_url)}"><span>{escape(self.name)}</span></div>'
```

![Custom Select2 rendering](../../../images/tutorial/configurations/modelview/select2_customization.png){ width="300" }
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ markdown_extensions:
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
- attr_list

plugins:
- search
Expand Down
2 changes: 1 addition & 1 deletion starlette_admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.7.0"
__version__ = "0.8.0"

from ._types import ExportType, RequestAction
from .actions import action
Expand Down

0 comments on commit a196b5f

Please sign in to comment.