Skip to content

Group Tree #101

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Group Tree #101

wants to merge 10 commits into from

Conversation

donald
Copy link
Member

@donald donald commented Sep 18, 2020

Prototype for #31

Let contact groups be arrange in a tree in the backend and give subgroups depth based indention in the dropdown menu. Code needs cleanup.

Add django-treebeard [1] to requirements. Note, that django-treebeard is
already requested by wagtail, because it is also used by wagtail for its
pages.

[1] https://django-treebeard.readthedocs.io/
Update requirements with

    (cd requirements && make)
Use MP_Node for Group and remove priority field.
Add migration. Add the column "path" without the unique constraint
and an invalid value first.

Next, go over all group objects and set a path from a
sequential index. Use alphabetical order, so that menus displayed be
tree are in the same order as before unless sorted by the admin.

As a last step add the unique contraint.
Add TreeAdmin for groups.

Note, that TreeAdmin is based on Djangos ModelAdmin, not on Wagtails
ModelAdmin. So we hook into Djangos admin-interface (available at
/django-admin)

Disable CSRF_COOKIE_HTTPONLY, because TreeAdmin uses Ajax over
http to arrange the group tree.
The <hr> before the "Reset filter" entry is not needed, because its at
the top of the box.

We already have a visual separation between "Reset filter" and the group
names, because the later are in the .dropdown-content div, which as a
little border.

Remove <hr> element.
Add groups in tree order instead of alphabetical order to the
context of the contacts page alphabetical order. Groups will be shown in
that order in the drop-down menu.
Add a method which can be used by a template to get a number of &nbsp;
entities based on the depth of the group,

Note: Yes, this is an ugly mixture of code and style. Should be fixed up
by some clever CSS using the depth attribute only.
Use Group.get_depth_fill method to get some indention into the group
pulldown menu.
@donald
Copy link
Member Author

donald commented Sep 25, 2020

Now the Wagtai ladmin "add group" page fail (depth NULL constraint)... Need more work.

Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant