added Admin function to sort trees
This commit is contained in:
parent
a0e9b88062
commit
cb330bc6e8
@ -89,9 +89,18 @@ class SyncLogAdmin(admin.ModelAdmin):
|
|||||||
admin.site.register(SyncLog, SyncLogAdmin)
|
admin.site.register(SyncLog, SyncLogAdmin)
|
||||||
|
|
||||||
|
|
||||||
|
@admin.action(description='Sort tree by name')
|
||||||
|
def sort_tree(modeladmin, request, queryset):
|
||||||
|
modeladmin.model.node_order_by = ['name']
|
||||||
|
with scopes_disabled():
|
||||||
|
Keyword.fix_tree(fix_paths=True)
|
||||||
|
modeladmin.model.node_order_by = []
|
||||||
|
|
||||||
|
|
||||||
class KeywordAdmin(TreeAdmin):
|
class KeywordAdmin(TreeAdmin):
|
||||||
form = movenodeform_factory(Keyword)
|
form = movenodeform_factory(Keyword)
|
||||||
ordering = ('space', 'path',)
|
ordering = ('space', 'path',)
|
||||||
|
actions = [sort_tree]
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Keyword, KeywordAdmin)
|
admin.site.register(Keyword, KeywordAdmin)
|
||||||
@ -138,6 +147,7 @@ admin.site.register(Unit)
|
|||||||
class FoodAdmin(TreeAdmin):
|
class FoodAdmin(TreeAdmin):
|
||||||
form = movenodeform_factory(Keyword)
|
form = movenodeform_factory(Keyword)
|
||||||
ordering = ('space', 'path',)
|
ordering = ('space', 'path',)
|
||||||
|
actions = [sort_tree]
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Food, FoodAdmin)
|
admin.site.register(Food, FoodAdmin)
|
||||||
|
Loading…
Reference in New Issue
Block a user