Skip to content

Commit cefe974

Browse files
committed
Add max_height to widget action props. Add highlight search results to widget action results. Add copy to clipboard to widget action results. Add expand results modal to widget action results. Add menu_section to model admins.
1 parent e907eec commit cefe974

18 files changed

Lines changed: 645 additions & 226 deletions

File tree

docs/build.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ def read_cls_docstring(cls):
4444

4545
def get_versions():
4646
return [
47+
{
48+
"version": "0.4.6",
49+
"changes": [
50+
"Add max_height to widget action props.",
51+
"Add highlight search results to widget action results.",
52+
"Add copy to clipboard to widget action results.",
53+
"Add expand results modal to widget action results.",
54+
"Add menu_section to model admins.",
55+
],
56+
},
4757
{
4858
"version": "0.4.5",
4959
"changes": [

docs/index.html

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ <h4 class="title">FastAdmin</h4>
192192

193193
<ul class="nav flex-column">
194194

195+
<li class="nav-item">
196+
<a class="nav-link" href="#v0_4_6">v0.4.6</a>
197+
</li>
198+
195199
<li class="nav-item">
196200
<a class="nav-link" href="#v0_4_5">v0.4.5</a>
197201
</li>
@@ -371,7 +375,7 @@ <h1>FastAdmin | Documentation</h1>
371375
<div class="row">
372376
<div class="col-sm-6 col-lg-4">
373377
<ul class="list-unstyled">
374-
<li><strong>Version:</strong> 0.4.5</li>
378+
<li><strong>Version:</strong> 0.4.6</li>
375379
<li>
376380
<strong>Author:</strong>
377381
<a href="mailto:vsdudakov@gmail.com" target="_blank">
@@ -388,7 +392,7 @@ <h1>FastAdmin | Documentation</h1>
388392
</li>
389393
<li>
390394
<strong>Updated:</strong>
391-
07 March 2026
395+
11 March 2026
392396
</li>
393397
</ul>
394398
</div>
@@ -951,6 +955,7 @@ <h3>Registering Models</h3>
951955

952956
@register(User)
953957
class UserModelAdmin(TortoiseModelAdmin):
958+
menu_section = "Users"
954959
list_display = ("id", "username", "is_superuser")
955960
list_display_links = ("id", "username")
956961
list_filter = ("id", "username", "is_superuser")
@@ -1545,6 +1550,7 @@ <h3>Registering Models</h3>
15451550

15461551
@register(User)
15471552
class UserModelAdmin(DjangoModelAdmin):
1553+
menu_section = "Users"
15481554
list_display = ("id", "username", "is_superuser")
15491555
list_display_links = ("id", "username")
15501556
list_filter = ("id", "username", "is_superuser")
@@ -1965,6 +1971,7 @@ <h3>Registering Models</h3>
19651971

19661972
@register(User, sqlalchemy_sessionmaker=sqlalchemy_sessionmaker)
19671973
class UserModelAdmin(SqlAlchemyModelAdmin):
1974+
menu_section = "Users"
19681975
list_display = ("id", "username", "is_superuser")
19691976
list_display_links = ("id", "username")
19701977
list_filter = ("id", "username", "is_superuser")
@@ -2449,6 +2456,7 @@ <h3>Registering Models</h3>
24492456

24502457
@register(User)
24512458
class UserModelAdmin(PonyORMModelAdmin):
2459+
menu_section = "Users"
24522460
list_display = ("id", "username", "is_superuser")
24532461
list_display_links = ("id", "username")
24542462
list_filter = ("id", "username", "is_superuser")
@@ -3661,6 +3669,10 @@ <h3>Methods and Attributes</h3>
36613669
class ModelAdmin(BaseModelAdmin):
36623670
"""This class is used to create admin model class."""
36633671

3672+
# Optional section name for grouping models in the left menu.
3673+
# Example of usage: menu_section = "Users"
3674+
menu_section: str | None = None
3675+
36643676
# Normally, objects have three save options: “Save”, “Save and continue editing”, and “Save and add another”.
36653677
# If save_as is True, “Save and add another” will be replaced
36663678
# by a “Save as new” button that creates a new object (with a new ID) rather than updating the existing object.
@@ -4008,6 +4020,7 @@ <h3>Registering Inlines</h3>
40084020

40094021
@register(User)
40104022
class UserModelAdmin(TortoiseModelAdmin):
4023+
menu_section = "Users"
40114024
list_display = ("id", "username", "is_superuser")
40124025
list_display_links = ("id", "username")
40134026
list_filter = ("id", "username", "is_superuser")
@@ -4602,6 +4615,7 @@ <h3>Registering Inlines</h3>
46024615

46034616
@register(User)
46044617
class UserModelAdmin(DjangoModelAdmin):
4618+
menu_section = "Users"
46054619
list_display = ("id", "username", "is_superuser")
46064620
list_display_links = ("id", "username")
46074621
list_filter = ("id", "username", "is_superuser")
@@ -5022,6 +5036,7 @@ <h3>Registering Inlines</h3>
50225036

50235037
@register(User, sqlalchemy_sessionmaker=sqlalchemy_sessionmaker)
50245038
class UserModelAdmin(SqlAlchemyModelAdmin):
5039+
menu_section = "Users"
50255040
list_display = ("id", "username", "is_superuser")
50265041
list_display_links = ("id", "username")
50275042
list_filter = ("id", "username", "is_superuser")
@@ -5506,6 +5521,7 @@ <h3>Registering Inlines</h3>
55065521

55075522
@register(User)
55085523
class UserModelAdmin(PonyORMModelAdmin):
5524+
menu_section = "Users"
55095525
list_display = ("id", "username", "is_superuser")
55105526
list_display_links = ("id", "username")
55115527
list_filter = ("id", "username", "is_superuser")
@@ -6190,6 +6206,7 @@ <h3>Methods and Attributes</h3>
61906206
width: (
61916207
tp.Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] | None
61926208
) = None, # width in 1-24 grid system
6209+
max_height: int | None = None,
61936210
):
61946211
"""Conveniently add attributes to a widget action function:
61956212

@@ -6253,6 +6270,7 @@ <h3>Methods and Attributes</h3>
62536270
wrapped.tab = tab
62546271
wrapped.title = title
62556272
wrapped.width = width
6273+
wrapped.max_height = max_height
62566274
if description is not None:
62576275
wrapped.short_description = description
62586276
return wrapped
@@ -6497,6 +6515,103 @@ <h2>Changelog</h2>
64976515

64986516

64996517

6518+
<section id="v0_4_6">
6519+
<h3>v0.4.6</h3>
6520+
6521+
6522+
6523+
<p class="text-4">
6524+
Add max_height to widget action props.
6525+
</p>
6526+
6527+
6528+
6529+
6530+
6531+
6532+
6533+
6534+
6535+
6536+
6537+
6538+
6539+
6540+
6541+
<p class="text-4">
6542+
Add highlight search results to widget action results.
6543+
</p>
6544+
6545+
6546+
6547+
6548+
6549+
6550+
6551+
6552+
6553+
6554+
6555+
6556+
6557+
6558+
6559+
<p class="text-4">
6560+
Add copy to clipboard to widget action results.
6561+
</p>
6562+
6563+
6564+
6565+
6566+
6567+
6568+
6569+
6570+
6571+
6572+
6573+
6574+
6575+
6576+
6577+
<p class="text-4">
6578+
Add expand results modal to widget action results.
6579+
</p>
6580+
6581+
6582+
6583+
6584+
6585+
6586+
6587+
6588+
6589+
6590+
6591+
6592+
6593+
6594+
6595+
<p class="text-4">
6596+
Add menu_section to model admins.
6597+
</p>
6598+
6599+
6600+
6601+
6602+
6603+
6604+
6605+
6606+
6607+
6608+
6609+
6610+
6611+
6612+
</section>
6613+
6614+
65006615
<section id="v0_4_5">
65016616
<h3>v0.4.5</h3>
65026617

examples/django_djangoorm/orm/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class Meta:
9999

100100
@register(User)
101101
class UserModelAdmin(DjangoModelAdmin):
102+
menu_section = "Users"
102103
list_display = ("id", "username", "is_superuser")
103104
list_display_links = ("id", "username")
104105
list_filter = ("id", "username", "is_superuser")

examples/fastapi_ponyorm/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
@register(User)
4040
class UserModelAdmin(PonyORMModelAdmin):
41+
menu_section = "Users"
4142
list_display = ("id", "username", "is_superuser")
4243
list_display_links = ("id", "username")
4344
list_filter = ("id", "username", "is_superuser")

examples/fastapi_sqlalchemy/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
@register(User, sqlalchemy_sessionmaker=sqlalchemy_sessionmaker)
3838
class UserModelAdmin(SqlAlchemyModelAdmin):
39+
menu_section = "Users"
3940
list_display = ("id", "username", "is_superuser")
4041
list_display_links = ("id", "username")
4142
list_filter = ("id", "username", "is_superuser")

examples/fastapi_tortoiseorm/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ async def upload_file(
5757

5858
@register(User)
5959
class UserModelAdmin(TortoiseModelAdmin):
60+
menu_section = "Users"
6061
list_display = ("id", "username", "is_superuser")
6162
list_display_links = ("id", "username")
6263
list_filter = ("id", "username", "is_superuser")

fastadmin/models/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ class InlineModelAdmin(BaseModelAdmin):
666666
class ModelAdmin(BaseModelAdmin):
667667
"""This class is used to create admin model class."""
668668

669+
# Optional section name for grouping models in the left menu.
670+
# Example of usage: menu_section = "Users"
671+
menu_section: str | None = None
672+
669673
# Normally, objects have three save options: “Save”, “Save and continue editing”, and “Save and add another”.
670674
# If save_as is True, “Save and add another” will be replaced
671675
# by a “Save as new” button that creates a new object (with a new ID) rather than updating the existing object.

fastadmin/models/decorators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def widget_action(
6969
width: (
7070
tp.Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] | None
7171
) = None, # width in 1-24 grid system
72+
max_height: int | None = None,
7273
):
7374
"""Conveniently add attributes to a widget action function:
7475
@@ -132,6 +133,7 @@ def decorator(func):
132133
wrapped.tab = tab
133134
wrapped.title = title
134135
wrapped.width = width
136+
wrapped.max_height = max_height
135137
if description is not None:
136138
wrapped.short_description = description
137139
return wrapped

fastadmin/models/helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ async def generate_models_schema(
245245
title=widget_action_function.title,
246246
tab=widget_action_function.tab,
247247
width=widget_action_function.width,
248+
max_height=getattr(widget_action_function, "max_height", None),
248249
description=getattr(widget_action_function, "short_description", None),
249250
widget_action_type=widget_action_function.widget_action_type,
250251
widget_action_props=widget_action_function.widget_action_props,
@@ -275,6 +276,7 @@ async def generate_models_schema(
275276
show_full_result_count=admin_model_obj.show_full_result_count,
276277
verbose_name=admin_model_obj.verbose_name,
277278
verbose_name_plural=admin_model_obj.verbose_name_plural,
279+
menu_section=getattr(admin_model_obj, "menu_section", None),
278280
# specific model fields
279281
fieldsets=admin_model_obj.fieldsets,
280282
save_on_top=admin_model_obj.save_on_top,

fastadmin/models/schemas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class ModelWidgetAction:
124124
description: str | None
125125
tab: str
126126
width: int | None
127+
max_height: int | None
127128
widget_action_type: WidgetActionType
128129
widget_action_props: WidgetActionChartProps | WidgetActionProps | None = None
129130
widget_action_filters: list[WidgetActionFilter] | None = None
@@ -211,6 +212,7 @@ class InlineModelSchema(BaseModelSchema):
211212
class ModelSchema(BaseModelSchema):
212213
"""Model schema"""
213214

215+
menu_section: str | None
214216
fieldsets: Sequence[tuple[str | None, dict[str, Sequence[str]]]] | None
215217
save_on_top: bool | None
216218
save_as: bool | None

0 commit comments

Comments
 (0)