mirror of
https://github.com/logos-co/open-law.git
synced 2025-01-09 22:35:50 +00:00
hotfix: collection.active_children
This commit is contained in:
parent
a4797e5ddb
commit
4cf5e2a2a2
@ -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
|
||||
|
@ -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 %}
|
||||
<li>
|
||||
<button type="button" id="callAddSectionModal" data-modal-target="add-section-modal" data-modal-toggle="add-section-modal" data-collection-id="{{collection.id}}" data-sub-collection-id="_" class="w-full block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">New Section</button>
|
||||
</li>
|
||||
@ -155,7 +155,7 @@
|
||||
<p class=" text-sm mb-3">{% if book.about==None %}About text{% else %}{{book.about}}{% endif %}</p>
|
||||
{% for collection in book.versions[-1].children_collections if not collection.is_root and not collection.is_deleted %}
|
||||
<p class="my-3 underline" id="collection-{{collection.label}}">#{{collection.label}}</p>
|
||||
{% if not collection.is_leaf and not collection.children %}
|
||||
{% if not collection.is_leaf and not collection.active_children %}
|
||||
<p class="ml-3 my-3 italic text-sm">Collection is empty</p>
|
||||
{% endif %}
|
||||
{{recursive_render("book/components/sub_collection_preview_content.html",collection,book)|safe}}
|
||||
|
@ -1,14 +1,14 @@
|
||||
{% if not collection.is_leaf %}
|
||||
<!-- if collection has sub_collection make for loop for it -->
|
||||
{% 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%}
|
||||
<p class="my-3" id="collection-{{sub_collection.label}}">
|
||||
##{{sub_collection.label}}
|
||||
</p>
|
||||
{% if not sub_collection.active_sections and not sub_collection.children %}
|
||||
{% if not sub_collection.active_sections and not sub_collection.active_children %}
|
||||
<p class="ml-3 my-3 italic text-sm">This sub collection is empty</p>
|
||||
{% endif %}
|
||||
<!-- prettier-ignore -->
|
||||
{% if sub_collection.children %}
|
||||
{% if sub_collection.active_children %}
|
||||
{{recursive_render("book/components/sub_collection_preview_content.html",sub_collection,book)|safe}}
|
||||
{% else %}
|
||||
<!-- prettier-ignore -->
|
||||
|
@ -3,7 +3,7 @@
|
||||
<!-- if collection has sub_collection make for loop for it -->
|
||||
<!-- Nested accordion -->
|
||||
<!-- prettier-ignore -->
|
||||
{% 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%}
|
||||
<div id="accordion-nested-collapse" data-accordion="open">
|
||||
<!-- prettier-ignore -->
|
||||
<div class="flex items-center justify-start w-full font-medium text-left text-gray-500 focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-800 dark:text-gray-400">
|
||||
@ -38,11 +38,11 @@
|
||||
|
||||
{% if access_to_create_collections or access_to_update_collections or access_to_create_section %}
|
||||
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200">
|
||||
{% if access_to_create_section and sub_collection.is_leaf and not sub_collection.children %}
|
||||
{% if access_to_create_section and sub_collection.is_leaf and not sub_collection.active_children %}
|
||||
<li>
|
||||
<button type="button" id="callAddSectionModal" data-modal-target="add-section-modal" data-modal-toggle="add-section-modal" data-collection-id="{{collection.id}}" data-sub-collection-id="{{sub_collection.id}}" class="w-full block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"> New Section </button>
|
||||
</li>
|
||||
{% elif not sub_collection.is_leaf and not sub_collection.children %}
|
||||
{% elif not sub_collection.is_leaf and not sub_collection.active_children %}
|
||||
{% if access_to_create_section %}
|
||||
<li>
|
||||
<button type="button" id="callAddSectionModal" data-modal-target="add-section-modal" data-modal-toggle="add-section-modal" data-collection-id="{{collection.id}}" data-sub-collection-id="{{sub_collection.id}}" class="w-full block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"> New Section </button>
|
||||
@ -92,7 +92,7 @@
|
||||
</div>
|
||||
<!-- prettier-ignore -->
|
||||
<div id="accordion-nested-collapse-body-{{sub_collection.parent.id}}-{{sub_collection.id}}" class="hidden" aria-labelledby="accordion-nested-collapse-heading-{{sub_collection.id}}">
|
||||
{% if sub_collection.children %}
|
||||
{% if sub_collection.active_children %}
|
||||
{{recursive_render("book/components/sub_collection_tab_content.html",sub_collection,book)|safe}}
|
||||
{% else %}
|
||||
<div class="ml-6">
|
||||
|
@ -34,7 +34,7 @@
|
||||
<span class="text-center dark:text-gray-300">{{ collection.label }}</span>
|
||||
</div>
|
||||
|
||||
{% for sub_collection in collection.children %}
|
||||
{% for sub_collection in collection.active_children %}
|
||||
<ul class="ml-4">
|
||||
<li>
|
||||
<div class="flex items-center space-x-2">
|
||||
|
@ -188,8 +188,8 @@ def collection_delete(book_id: int, collection_id: int):
|
||||
collection: m.Collection = db.session.get(m.Collection, collection_id)
|
||||
|
||||
collection.is_deleted = True
|
||||
if collection.children:
|
||||
for child in collection.children:
|
||||
if collection.active_children:
|
||||
for child in collection.active_children:
|
||||
child: m.Collection
|
||||
delete_nested_collection_entities(child)
|
||||
log(log.INFO, "Delete subcollection [%s]", collection.id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user