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

Exclude empty albums from album list (for non-owner) #57

Open
sandino opened this issue Aug 15, 2015 · 0 comments
Open

Exclude empty albums from album list (for non-owner) #57

sandino opened this issue Aug 15, 2015 · 0 comments

Comments

@sandino
Copy link

sandino commented Aug 15, 2015

Sometimes users create albums but do not upload images (sometimes they do it later). Though empty albums are not displayed to non-owner, they are still included in queryset in AlbumListView. Thus, e.g., if IMAGESTORE_ALBUMS_ON_PAGE = 12 and one of albums has no images (and therefore no head) and non-owner opens imagestore:index page, there will be only 11 albums on page.

By this reason some precisely built pages are displayed not very neat way. I suggest excluding such albums from queryset (to insert before return albums):

    if self.request.user.is_authenticated():
        albums = albums.exclude(Q(head__isnull=True), ~Q(user=self.request.user))
    else:
        albums = albums.exclude(head__isnull=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant