diff --git a/app/models/collection.py b/app/models/collection.py index 5b0f226..6c631e9 100644 --- a/app/models/collection.py +++ b/app/models/collection.py @@ -37,6 +37,10 @@ class Collection(BaseModel): def active_sections(self): return [section for section in self.sections if not section.is_deleted] + @property + def active_children(self): + return [child for child in self.children if not child.is_deleted] + @property def book_id(self): return self.version.book_id diff --git a/app/templates/book/collection_view.html b/app/templates/book/collection_view.html index e7557e6..c0b8a49 100644 --- a/app/templates/book/collection_view.html +++ b/app/templates/book/collection_view.html @@ -81,7 +81,7 @@ {% endif %} {% endif %} {% if access_to_create_section %} - {% if collection.children|length ==0 or collection.children|length ==0 and collection.is_leaf %} + {% if collection.active_children|length ==0 or collection.active_children|length ==0 and collection.is_leaf %}
  • @@ -155,7 +155,7 @@

    {% if book.about==None %}About text{% else %}{{book.about}}{% endif %}

    {% for collection in book.versions[-1].children_collections if not collection.is_root and not collection.is_deleted %}

    #{{collection.label}}

    - {% if not collection.is_leaf and not collection.children %} + {% if not collection.is_leaf and not collection.active_children %}

    Collection is empty

    {% endif %} {{recursive_render("book/components/sub_collection_preview_content.html",collection,book)|safe}} diff --git a/app/templates/book/components/sub_collection_preview_content.html b/app/templates/book/components/sub_collection_preview_content.html index 8ca2ca0..b2724b0 100644 --- a/app/templates/book/components/sub_collection_preview_content.html +++ b/app/templates/book/components/sub_collection_preview_content.html @@ -1,14 +1,14 @@ {% if not collection.is_leaf %} -{% for sub_collection in collection.children if not sub_collection.is_deleted%} +{% for sub_collection in collection.active_children if not sub_collection.is_deleted%}

    ##{{sub_collection.label}}

    -{% if not sub_collection.active_sections and not sub_collection.children %} +{% if not sub_collection.active_sections and not sub_collection.active_children %}

    This sub collection is empty

    {% endif %} -{% if sub_collection.children %} +{% if sub_collection.active_children %} {{recursive_render("book/components/sub_collection_preview_content.html",sub_collection,book)|safe}} {% else %} diff --git a/app/templates/book/components/sub_collection_tab_content.html b/app/templates/book/components/sub_collection_tab_content.html index b935b00..7427364 100644 --- a/app/templates/book/components/sub_collection_tab_content.html +++ b/app/templates/book/components/sub_collection_tab_content.html @@ -3,7 +3,7 @@ - {% for sub_collection in collection.children if not sub_collection.is_deleted%} + {% for sub_collection in collection.active_children if not sub_collection.is_deleted%}
    @@ -38,11 +38,11 @@ {% if access_to_create_collections or access_to_update_collections or access_to_create_section %}