Skip to content

Commit

Permalink
Merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyue92tree committed Jul 5, 2023
2 parents 6f86a4a + 1799d26 commit ece16c6
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 11 deletions.
2 changes: 1 addition & 1 deletion adminlteui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = '2.1.0'
version = '2.1.1'
default_app_config = 'adminlteui.apps.AdminlteUIConfig'
9 changes: 5 additions & 4 deletions adminlteui/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ def make(self, request, models=None, deep=1, deep_limit=0):
if not self.name:
menu_item['name'] = model.get('name')
menu_item['url'] = model.get('admin_url')
# show menu active when access child url, add/change... page
if menu_item['url'] in request.path:
menu_item['active'] = True
elif self.menu_type == 'link':
menu_item['url'] = self.url
# check permissions when permissions are not None
if self.permissions:
if request.user.has_perms(self.permissions) is False:
return None
if menu_item['url'] == request.path:
menu_item['active'] = True
else:
# menu_type: group and child is empty will hide the menu
if not self.child:
Expand All @@ -55,10 +60,6 @@ def make(self, request, models=None, deep=1, deep_limit=0):
menu_item['target_blank'] = self.target_blank
menu_item['menu_type'] = self.menu_type or 'group'

if menu_item['menu_type'] != 'group':
if menu_item['url'] == request.path:
menu_item['active'] = True

if self.child:
if deep_limit == 0 or deep <= deep_limit:
child_list = []
Expand Down
9 changes: 7 additions & 2 deletions adminlteui/templates/adminlte/date_range_filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@
});
$drp_input.on('cancel.daterangepicker', function(ev, picker) {
$drp_input.val('{{ title }}')
$('#id_filter_{{ field_name }}__gte').attr('name', '').val('');
$('#id_filter_{{ field_name }}__lte').attr('name', '').val('');
$('#id_filter_{{ field_name }}__gte').removeAttr('name').val('');
$('#id_filter_{{ field_name }}__lte').removeAttr('name').val('');
});
$drp_input.on('change', function(ev) {
$drp_input.val('{{ title }}')
$('#id_filter_{{ field_name }}__gte').removeAttr('name').val('');
$('#id_filter_{{ field_name }}__lte').removeAttr('name').val('');
});
// set initial value
var range = "{{ choices.0.value }}";
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/en/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ChangeLog

## [v2.1.0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/2.1.0)
- add date range filter base on daterangepicker
- add min-width for all filter
- change object-tools position
- update locale
- calculate menu active status from server

## [v2.0.0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/2.0.0)
- remove `django-treebeard` deps, fix #28, #29, #30
- remove all adminlte models, make simple
Expand Down
22 changes: 20 additions & 2 deletions docs/en/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ top menu,default is `[]`,will show nothing
> Tips: Top menu will not show icon,only support secondary menu max
## ModelAdmin
external ModelAdmin in django
### external ModelAdmin in django

- make table filter support `select2` in `change_list` page
- custom search field placeholder for `change_list` page
Expand All @@ -109,6 +109,24 @@ effect

![modeladmin](../assets/images/modeladmin.png)

### Custom Filters
#### DateRangeFilter

example:
```python title='rap/admin.py'
from adminlteui.admin import ModelAdmin
from adminlteui.filters import DateRangeFilter

class AutomationTaskRecordAdmin(CommonAdmin, ModelAdmin):
list_display = ('id', 'automation', 'account', 'status', 'start_time',
'end_time', 'update_time')
list_filter = ('automation__project', 'automation__source',
'status', ('start_time', DateRangeFilter), ('end_time', DateRangeFilter))

```
effect:
![adminlte_date_range_filter](../assets/images/adminlte_date_range_filter.png)

## Widgets

### AdminlteSelect
Expand Down Expand Up @@ -146,4 +164,4 @@ class CollectorAdmin(admin.ModelAdmin):
```
effect:

![adminlte_select](../assets/images/adminlte_select_multiple.png)
![adminlte_select_multiple](../assets/images/adminlte_select_multiple.png)
1 change: 1 addition & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ INSTALLED_APPS = [
## Features

- [Custom General Option](/django-adminlte-ui/2.x/guide/#basic-info)
- [ModelAdmin](/django-adminlte-ui/2.x/guide/#modeladmin)
- [Widgets](/django-adminlte-ui/2.x/guide/#widgets)
- [Custom Menu](/django-adminlte-ui/2.x/guide/#menu)

Expand Down
8 changes: 8 additions & 0 deletions docs/zh/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 更新说明


## [v2.1.0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/2.1.0)
- 新增基于daterangepicker的时间过滤器
- 为所有的filter新增min-width样式
- 调整change_list视图object-tools的位置,与actions处于同一行
- 更新locale
- 在服务器端计算菜单的活跃状态,原来通过js在浏览器实现

## [v2.0.0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/2.0.0)
- 移除 `django-treebeard` 依赖包, 同时修复 #28, #29, #30
- 移除了所有models,不再通过数据库的方式管理自定义菜单及其他选项
Expand Down
24 changes: 22 additions & 2 deletions docs/zh/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MyAdminlteConfig(AdminlteConfig):
> Tips: 顶部菜单将不显示Icon,并且最多显示二级菜单,多余的将被隐藏
## ModelAdmin
扩展django的ModelAdmin
### 扩展django的ModelAdmin

-`change_list`页面的table过滤器支持`select2`
- 自定义`change_list`页面搜索框的placeholder提示
Expand All @@ -109,6 +109,26 @@ class CollectorModelAdmin(ModelAdmin):

![modeladmin](../assets/images/modeladmin.png)

### Filters过滤器
#### DateRangeFilter

基于datarangepicker的时间范围过滤器

示例:
```python title='rap/admin.py'
from adminlteui.admin import ModelAdmin
from adminlteui.filters import DateRangeFilter

class AutomationTaskRecordAdmin(CommonAdmin, ModelAdmin):
list_display = ('id', 'automation', 'account', 'status', 'start_time',
'end_time', 'update_time')
list_filter = ('automation__project', 'automation__source',
'status', ('start_time', DateRangeFilter), ('end_time', DateRangeFilter))

```
效果图:
![adminlte_date_range_filter](../assets/images/adminlte_date_range_filter.png)

## Widgets组件

### AdminlteSelect
Expand Down Expand Up @@ -146,4 +166,4 @@ class CollectorAdmin(admin.ModelAdmin):
```
效果图:

![adminlte_select](../assets/images/adminlte_select_multiple.png)
![adminlte_select_multiple](../assets/images/adminlte_select_multiple.png)
1 change: 1 addition & 0 deletions docs/zh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ INSTALLED_APPS = [
## 功能

- [自定义属性](/django-adminlte-ui/2.x/zh/guide/#_4)
- [ModelAdmin扩展](/django-adminlte-ui/2.x/zh/guide/#modeladmin)
- [Widget组件](/django-adminlte-ui/2.x/zh/guide/#widgets)
- [自定义菜单](/django-adminlte-ui/2.x/zh/guide/#_5)

Expand Down

0 comments on commit ece16c6

Please sign in to comment.