Closed GoogleCodeExporter closed 9 years ago
I took a look at this some time ago, main issue was that it had to be an Ajax
admin
because of branch reordering. So I took a look at the two libraries I've used
before:
- ExtJS, It has trees with columns (
http://extjs.com/deploy/dev/examples/tree/column-tree.html ) and branch
reordering (
http://extjs.com/deploy/dev/examples/tree/reorder.html ), but I think their new
(completely bizarre) licensing policies would force treebeard to become GPL. So
sadly
we can't use this.
- YUI, it has branch reordering, but not trees with columns.
All the other javascript trees with columns and branch reordering I've seen are
either commercial or addons to other libraries (like
http://www.bernardopadua.com/nestedSortables/test/widget/ ).
Original comment by gpicon
on 10 Nov 2008 at 1:19
I've added a custom admin page to manage the tree hierarchy with ExtJS and
double clicking on a node takes me
to a slightly modified standard django "Change <model> admin page. This meets
my needs for this application.
I've chosen ExtJS, but the same could have been done with just YUI. It would
have been nice to have something
like what I've done out of the box, built in.
Original comment by kemalisp...@gmail.com
on 11 Jan 2009 at 5:48
@kemalispirli:
I agree it would have been nice to have. To be honest, the main blocker for this
ticket at the moment is that I don't use the django admin at all. Maybe you
could
contribute your treebeard-admin code? (note that if distributed it would have
to be GPL).
Original comment by gpicon
on 12 Jan 2009 at 8:29
@kemalispirli:
Is there any chance you could share your tree extensions to the admin with us?
It
would save us a lot of trouble reinventing the wheel.
Thanks!
Original comment by devel...@gmail.com
on 26 May 2009 at 9:14
Uh I just noticed a typo in my previous comment. What I meant was that
contributions CAN'T be GPLed (since it's
incompatible with the Apache License 2.0 used by treebeard).
Apache/BSD/MIT/similar licenses are ok.
Please not that I don't use the django admin interface and I don't test
treebeard with the admin at all. So the only
hope of including some kind of admin interface support in the distribution (or
as a separate contrib package) is
for somebody to be a good open source citizen and contribute what they have :)
Original comment by gpicon
on 14 Jun 2009 at 8:19
I have a very basic implementation working that does not require any Javascript
or
Ajax calls. It works by adding a column to the change list which contains a
form for
each row. The form is adapted from django-mptt. Essentially, it is two
drop-downs.
One to select the move operation. The other to select the target relative node.
To display the tree itself, I created a new version of the result_list tag used
by
the change_list.html template. This tag is responsible for forcing the
sort-order of
the tree, and adding nbsp's in front of the item name in order to display the
tree
heirarchy.
There is one problem with this approach: I am using the "tree_id" and "lft"
fields to
sort the tree. This only works for NS_Tree. In order to make this work for the
other
tree types, the result_treelist tag needs to enforce the order for all three
tree
types, and I'm not exactly sure how to do that. It is easy for NS_Tree, as
there are
actual fields that can be referenced by the ORM. The sort is simply an .order_by
clause. I will work on packaging up the code as a patch as it is so far.
Original comment by mwdi...@gmail.com
on 18 Jul 2009 at 1:21
@mwdiers
That's great news! I'll wait for your patch :) Hopefully making it work with MP
and AL won't be that hard.
Original comment by gpicon
on 18 Jul 2009 at 2:07
I am struggling with this. The trouble is with the filtering of an item list, or
working with a list of items that has already been filtered and displaying that
list
in DFS order.
I have found no practical way to do this. The Treebeard custom Managers do not
sort
MP or NS trees, period. I thought they did, but they don't. All the custom
Managers
do in MP or NS trees is overide the delete method in their corresponding
Queryset
class. In both cases, get_tree() simply returns Model.objects.all(), unsorted.
Only
the AL trees are returned sorted by their custom Managers.
So really, until this is addressed in treebeard, it really isn't going to be
possible
to create a ui that works for all three tree types.
Original comment by mwdi...@gmail.com
on 21 Jul 2009 at 11:40
I've created (basing on the mptt admin patch) a simple admin interface for
treebeard.
It uses nestedsortable
(http://code.google.com/p/nestedsortables/wiki/NestedSortableDocumentation) for
representing the tree.
I have used it only with MP_Node, so I don't know if it works with other kind of
nodes, but I think it's a good start for the admin.
Attached is a diff, with added admin.py and change list template (I'm not sure
if
that's the correct location for a template file, I just copy it to my
application
templates) and media files to be placed in application media dir.
To use this admin one only (besides the template and media files placement)
needs to
create a class extending TreebeardModelAdmin.
from treebeard.admin import TreebeardModelAdmin
class CategoryAdmin(TreebeardModelAdmin):
pass
Optionally provide a "position_field" variable, which will contain integer
field that
will be used for sorting of the tree. (this variable will be rewritten every
time the
tree is changed, so it can't be the node_order_by)
from treebeard.admin import TreebeardModelAdmin
class CategoryAdmin(TreebeardModelAdmin):
position_field = "position"
It's not a clean solution (I'm just starting with django) but maybe it will
help someone.
Original comment by Krzyszto...@gmail.com
on 1 Aug 2009 at 7:38
Attachments:
I'd be happy with something as simple as including a parent_id column, and just
being
able to create or select the parent node in the admin interface. Would this
not be
the simplest solution?
Original comment by james%ic...@gtempaccount.com
on 11 Aug 2009 at 4:18
I think the simplest solution would be one that does not depend on javascript.
While
drag-and-drop is nice, I believe a non-javascript solution would be more
likely to
make it into trunk, as it does not need to play favorites with any particular
library.
My proposal would be to just display the changelist as a "tree-table" (i.e., the
first column is indented), and have reparenting and ordering done within the
item
edit screen (although, we can still put ordering in the changelist if we wanted
to
with up/down links).
Original comment by bendavi...@gmail.com
on 11 Sep 2009 at 4:42
@mwdiers:
Regarding the lack of ordering in MP and NS trees, are you sure it's not the
same problem reported in issue 9 ?
There are warnings in the documentation for when you add a Meta class in your
MP/NS models (you must add
the ordering again).
Original comment by gpicon
on 4 Oct 2009 at 4:47
@Krzysztof.Krason:
I created a branch to test your patches in r107:
http://code.google.com/p/django-
treebeard/source/browse/#svn/branches/admin
In r108 I commited your patches (with a minor modification to use unicode()
instead of .__unicode__ ), and
updated the tbexample app to have the admin enabled. So far it seems to work
with all tree types, including
moving (doing informal tests), but I can't see the entire trees and there is no
paginator. Please let me know if
there is something I am missing.
Original comment by gpicon
on 4 Oct 2009 at 11:46
james, bendavis:
I'm testing Krzystof's patches basically because of a very important open
source principle:
There is actual code, and actual code _now_ is better than awesome perfect
godlike code maybe never.
Also, avoiding a specific javascript library and/or javascript in the admin at
all, BUT, I don't see a better way
to handle a very common operation on trees: moving nodes and reparenting.
Something Krzystof's got
working in his patch.
Original comment by gpicon
on 4 Oct 2009 at 11:53
(last comment should read):
Also, avoiding a specific javascript library and/or javascript in the admin at
all *IS A VALID POINT*, ...
Original comment by gpicon
on 4 Oct 2009 at 11:54
Here is yet another solution without javascript, I hope someone might find it
useful.
I did not patch anything in the default django installation, just subclassed it.
To get it working, put content of the archive to the root of your project and
add '<project name>.admin' to
the list of INSTALLED_APPS in the settings.py (this is required to allow
templates inclusion).
Then, in your app models.py:
from <project name>.admin.models import TreeAdmin
admin.site.register(Category, TreeAdmin)
(given that <project name> is your project name and 'Category' is a treebeard
model class you want to
manage).
I tested it with MP_Node only, but it should work with other tree
implementations as well.
Original comment by aleh...@gmail.com
on 5 Oct 2009 at 1:17
Attachments:
@aleh.fl
Thanks for the code! I happened to need this functionality today. Appears to be
working well so far (I'm using
MP_Node as well). I'm about to work with some fairly large trees of data
(biology taxonomy trees), so I'll see if I
can contribute anything back here as the project progresses.
Original comment by larry.ku...@gmail.com
on 9 Oct 2009 at 9:32
@alex.fl
Thanks a lot for your patch. I created a branch to test it with an updated
tbexample module:
http://code.google.com/p/django-treebeard/source/browse/#svn/branches/admin-aleh
It looks great! I can see the whole tree :) I'll test how moving nodes work now.
(I also renamed branches/admin to branches/admin-krzysztof to avoid confusion)
Original comment by gpicon
on 11 Oct 2009 at 10:13
@aleh.fl
Ok it's not working on sorted trees because it's using "first-child", "left"
and "right" as pos parms :)
Sorted trees can only take "sorted-child" and "sorted-sibling" as pos.
Original comment by gpicon
on 11 Oct 2009 at 10:24
@gpicon
re: it's not working on sorted trees
Thanks for finding that out. I will try to correct that.
Original comment by aleh...@gmail.com
on 12 Oct 2009 at 10:12
Made it working with sorted trees.
Fixed version is in attachment.
Original comment by aleh...@gmail.com
on 12 Oct 2009 at 2:18
Attachments:
@aleh.fl
Excellent I commited the patch in r112
Please guys, if you're subscribed to this ticket, test the admin-aleh branch :)
Nice work aleh!
Original comment by gpicon
on 13 Oct 2009 at 6:18
I migrated the svn repo to hg. All the tags and branches are still there. Type
"hg update admin-aleh" after
cloning to test aleh's admin branch.
Original comment by gpicon
on 14 Oct 2009 at 4:37
Moved the admin stuff from tbadmin to treebeard.admin and treebeard.forms
Updated the tbexample app to use the new locations.
Original comment by gpicon
on 16 Oct 2009 at 5:23
Found bug in my tree-admin implementation.
If you edit some root node, the node itself is not excluded from 'Relative to:'
drop-down, so it is possible to
submit bad parent node id.
Please see fix attached.
Original comment by aleh...@gmail.com
on 16 Oct 2009 at 4:17
Attachments:
Aleh, thanks, I applied the patch in
http://code.google.com/p/django-treebeard/source/detail?
r=8d82de7b95b5c46a89f6c62ad97f7cce8e3b41de
Original comment by gpicon
on 17 Oct 2009 at 5:10
Ok merged everything in
http://code.tabo.pe/django-treebeard/changeset/fd05b25fbbd8/ (yeah I moved
everything to bitbucket).
Thanks Aleh!
Original comment by gpicon
on 24 Oct 2009 at 5:46
I've been struggling to get the custom change_list to display with this patch.
I just installed from the merged link above. I'm seeing all the fields for
dealing with the tree in the model instance edit view, but nothing on the
change list view. I have just added 'treebeard' to my apps, did syncdb,
everything else seems to be working. I tried explicitly adding the absolute
path for change_list_template in treebeard/admin.py, to no effect. Any thought
on what I could be missing?
Original comment by swihart....@gmail.com
on 6 Sep 2010 at 5:22
Original issue reported on code.google.com by
yann.ma...@gmail.com
on 10 Nov 2008 at 2:00