Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection hierarchy #3407

Closed
wants to merge 71 commits into from

Conversation

trumpet2012
Copy link
Contributor

@trumpet2012 trumpet2012 commented Feb 27, 2017

This PR is for adding hierarchical support for Collections to the admin interface #3380.

This has quickly become a rather large PR so I wanted to go ahead and open it so you guys could give feedback as I go along.

Screenshots at current state (2/27/2017)

http://imgur.com/a/Q5DPK

Screenshots (3/2/2017)

http://imgur.com/a/BPnrf

TODO:

  • Testing
    • Fix existing tests
    • Test AdminCollectionChooserWidget
    • Test Collection views
    • Test Collection chooser
    • Test CollectionChooserPanel
    • Test Collection Management Permissions
    • And probably more
  • Documentation
  • Collection Chooser
    • Updated existing collections view to support the chooser modal
    • Created templates for the collection chooser.
    • Added searching to the collection chooser
    • Added the collection chooser to the Groups admin page
    • Updated the Documents admin to use the chooser
    • Update the Images admin to use the chooser
    • May need to tweak some styling
    • Handle opening collection modal from Image/Document choosers
  • Collection Admin
    • Updated the admin to support navigating through the tree of collections
    • Updated the delete view for collections to handle checking if any of its children collections contain content before allowing it to be delete.
    • Created new group permission class GroupCollectionManagementPermission to control which groups of users can make changes to which part of the collection tree. (Works like Pages)
    • Created UserCollectionPermissionsProxy and CollectionPermissionTester for handling checking a users access level for collections (just like the Proxy and Tester for Page)
    • Created a CollectionChooserPanel
    • Support moving collections around in the tree

…eQueryset, since it is not specific to pages and can be used for Collection navigation as well.
… out logic from `get_pages_with_direct_explore_permission` into a separate helper method, to be reused for collections.
…tion. Updated index view to display a collections children.
…o be different from those on `GroupCollectionPermission`.
…management of collections can be controlled per group.
…issions a user has for a particular collection.
… Created hook for registering the collection listing buttons.
…ton templatetag. Also applied some styling/structural tweaks.
… any of its children collections contain any content.
… determining whether or not the user should be given access. Fixed issue where `get_collections_with_direct_explore_permission` could contain the same Collection multiple times.
@trumpet2012
Copy link
Contributor Author

Hey guys,

So there is still some work that needs to be done on this, such as writing tests and fixing nested modal issues.

Before I spend a lot more time working on this, is this something you guys would be willing to look at any time soon?

@frague59
Copy link

frague59 commented Jun 15, 2017

+1 to have this in next reelase...

@gasman gasman added this to the 2.0 milestone Oct 6, 2017
@gasman gasman added this to Planned for 2.0 in Roadmap Nov 7, 2017
@tomdyson tomdyson requested a review from chosak November 15, 2017 17:12
@tomdyson
Copy link
Contributor

@trumpet2012, I'm really sorry that it's taken us so long to respond to this impressive piece of work. I think we were all slightly terrified by the scale of it! We have just been discussing your PR in our core team meeting, and @chosak has kindly agreed to give it an initial review.

We'd like to include this in the next release, if possible. Will you have time to write the new tests in the next few weeks?

@trumpet2012
Copy link
Contributor Author

@tomdyson That is awesome to hear!

Aside from creating new tests and fixing conflicts, the only other issue I know of is how to handle the nested modals, such as opening the collection chooser from the image/document chooser. I explain the problem in greater detail here: https://groups.google.com/forum/?pli=1#!topic/wagtail-developers/8wVNtiYnPF8.

The next few weeks are gonna be a little crazy here with Thanksgiving and then Christmas around the corner. I'm talking with my company about the possibility of me being able to use my work time to work on this. This is a feature they want to see implemented, but we have other scheduled development ongoing. Regardless, I will try and make some time to work on this.

What does the timeline look like for the 2.0 release? I assume you guys want to release around the same time as Django 2.0.

Copy link
Member

@chosak chosak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the timeline look like for the 2.0 release?

The current plan is to release 2.0 in early December, shortly after Django 2.0 is released.

@trumpet2012 this is a nice improvement, thank you for contributing!

I took a stab at squashing and rebasing to try to review this PR (my branch is here). There seems to be some overlap with how collection view restrictions were implemented in #3644 (View restrictions for documents). Do you have any thoughts as to how to best reconcile?

There are some front-end styling things that others might be better suited to review, e.g. this.

This PR is quite large, and it would be nice to somehow break it down somehow into a few smaller pieces. My first thought is perhaps it'd be best to defer the new collection chooser. This would eliminate the "move" functionality (which doesn't seem so critical) and simplify integration into the image/document chooser views. For those could we instead use a modified version of the current dropdown that visually indicates the nesting using e.g. Root, -- Child, ---- Grandchild?

At a high level integration of the collection chooser nested inside of the image/document chooser feels a bit messy. Are there other examples of this kind of nesting in Wagtail? The modifications this requires to e.g. the generic index view feel a bit overly complex.

@@ -34,6 +34,10 @@ header {
.left {
float: left;

@media screen and (max-width: $breakpoint-mobile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the motivation behind this specific change? This seems like it'd affect the header on all admin pages.

@@ -84,6 +84,105 @@ def not_ancestor_of(self, other, inclusive=False):
"""
return self.exclude(self.ancestor_of_q(other, inclusive))

def first_common_ancestor(self, include_self=False, strict=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change modify anything, or is it just moving the method from below? Can this change be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it from PageQuerySet to TreeQuerySet since this logic is generic enough to be used for any treebeard tree. This way it can be used for collection tree navigation.


return context

def get(self, request, root_id=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this endpoint handle both the browse and (nested) chooser feels a bit complicated, although unfortunately I don't have a cleaner approach off the top of my head. See other comment on wagtailadmin/views/generic.py.

return context

def get(self, request):
context = self.get_context()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change conflicts with (and breaks) the default list view handling introduced in #3625. See default Django behavior here that supports both self.template_name and self.get_template_names() as possible template sources.

@rafaponieman
Copy link

Hello, and thank you!

I was wondering if this implementation could somehow be used for other treebeard hierarchies, for example, on the modeladmin contrib.

…eviously addressed issue with overlapping menu icon and header, which should have since been resolved in newer wagtail versions.
@trumpet2012
Copy link
Contributor Author

trumpet2012 commented Nov 30, 2017

@chosak

I took a stab at squashing and rebasing to try to review this PR (my branch is here).

What is the best way to work off of your changes? I'm working on pulling in the latest Wagtail changes as well. I sent you an invite so that you could have write access to this branch if you need it.

There seems to be some overlap with how collection view restrictions were implemented in #3644 (View restrictions for documents). Do you have any thoughts as to how to best reconcile?

Need to figure out what exactly the overlap between the two is. The collection permissions I added are intended to control which users can add/edit/delete collections from the admin.

This PR is quite large, and it would be nice to somehow break it down somehow into a few smaller pieces. My first thought is perhaps it'd be best to defer the new collection chooser.

Yeah I think that makes sense. In hindsight, I should have done it like that from the beginning. Using the dropdown box should work as a first out. I will work on taking out the chooser and doing the dropdown. Is the idea of having a collection chooser modal something that makes sense to you guys as a future implementation?

Are there other examples of this kind of nesting in Wagtail?

I have been unable to find anywhere this has been done before. I agree that it doesn't feel clean.

The modifications this requires to e.g. the generic index view feel a bit overly complex.

It looks like the implementation of the Wagtail generic index view has changed considerably since I last looked at this. I would be able to get the modal working without modifying the generic index view now.

@trumpet2012
Copy link
Contributor Author

@rafaponieman This implementation is very collection centric. As it stands, it could not be used to handle other treebeard hierarchies. It is likely out of scope to try and make this generic.

@chosak
Copy link
Member

chosak commented Nov 30, 2017

@trumpet2012 thanks for following up!

What is the best way to work off of your changes?

You could branch off of mine if you like, or, if you're amenable, I would probably recommend opening a brand new PR off of current master, and pull in relevant changes without the chooser (using a simplified dropdown as proposed). Optionally you could try to remove from this PR and merge in all the necessary changes, but it might be easier to start with a new branch.

I sent you an invite

Thanks, I saw that, but that's not necessary. It's probably best if you rescind that invitation, honestly, as there's no need for me to be part of your company's private organization.

Is the idea of having a collection chooser modal something that makes sense to you guys as a future implementation?

Personally I think this could be useful if someone has a large number of collection. As there doesn't appear to be any other nested modals, it'd require some higher-level thinking about how best to implement.

@patta42
Copy link
Contributor

patta42 commented Nov 30, 2017

Personally I think this could be useful if someone has a large number of collection. As there doesn't appear to be any other nested modals, it'd require some higher-level thinking about how best to implement.

I work on migrating a website to wagtail that has been around since 2004. It's the website of a society and they do regular events every year. The website has about 100 photos per event and about 30 events per year. I would very much welcome a collection chooser that is not only a select box.

Just as an idea, maybe something similar to the flyout menu for Pages in the admin might be easier to implement than nested modals.

@trumpet2012 trumpet2012 mentioned this pull request Dec 6, 2017
6 tasks
@trumpet2012
Copy link
Contributor Author

trumpet2012 commented Dec 6, 2017

@chosak I took your advice and recreated the appropriate changes on a new branch off of master. See #4106.

@chosak
Copy link
Member

chosak commented Dec 6, 2017

@trumpet2012 excellent, I'll close this PR and give the new one a review.

@chosak chosak closed this Dec 6, 2017
@gasman gasman moved this from Planned for 2.0 to Planned for 2.1 in Roadmap Jan 3, 2018
@gasman gasman removed this from Planned for 2.1 in Roadmap Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants