Skip to content

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

@sandino

Description

@sandino

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions