udata 11.0.2.dev23__py3-none-any.whl → 11.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/__init__.py +0 -1
- udata/core/topic/models.py +13 -2
- udata/migrations/2025-10-01-delete-orphaned-topic-elements.py +30 -0
- udata/static/chunks/{10.8ca60413647062717b1e.js → 10.471164b2a9fe15614797.js} +3 -3
- udata/static/chunks/{10.8ca60413647062717b1e.js.map → 10.471164b2a9fe15614797.js.map} +1 -1
- udata/static/chunks/{11.b6f741fcc366abfad9c4.js → 11.83535504cd650ea08f65.js} +3 -3
- udata/static/chunks/{11.b6f741fcc366abfad9c4.js.map → 11.83535504cd650ea08f65.js.map} +1 -1
- udata/static/chunks/{13.2d06442dd9a05d9777b5.js → 13.d9c1735d14038b94c17e.js} +2 -2
- udata/static/chunks/{13.2d06442dd9a05d9777b5.js.map → 13.d9c1735d14038b94c17e.js.map} +1 -1
- udata/static/chunks/{17.e8e4caaad5cb0cc0bacc.js → 17.81c57c0dedf812e43013.js} +2 -2
- udata/static/chunks/{17.e8e4caaad5cb0cc0bacc.js.map → 17.81c57c0dedf812e43013.js.map} +1 -1
- udata/static/chunks/{19.f03a102365af4315f9db.js → 19.df16abde17a42033a7f8.js} +3 -3
- udata/static/chunks/{19.f03a102365af4315f9db.js.map → 19.df16abde17a42033a7f8.js.map} +1 -1
- udata/static/chunks/{8.778091d55cd8ea39af6b.js → 8.462bb3029de008497675.js} +2 -2
- udata/static/chunks/{8.778091d55cd8ea39af6b.js.map → 8.462bb3029de008497675.js.map} +1 -1
- udata/static/chunks/{9.033d7e190ca9e226a5d0.js → 9.07515e5187f475bce828.js} +3 -3
- udata/static/chunks/{9.033d7e190ca9e226a5d0.js.map → 9.07515e5187f475bce828.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/test_topics.py +13 -1
- {udata-11.0.2.dev23.dist-info → udata-11.1.1.dist-info}/METADATA +1 -2
- {udata-11.0.2.dev23.dist-info → udata-11.1.1.dist-info}/RECORD +26 -25
- {udata-11.0.2.dev23.dist-info → udata-11.1.1.dist-info}/WHEEL +0 -0
- {udata-11.0.2.dev23.dist-info → udata-11.1.1.dist-info}/entry_points.txt +0 -0
- {udata-11.0.2.dev23.dist-info → udata-11.1.1.dist-info}/licenses/LICENSE +0 -0
- {udata-11.0.2.dev23.dist-info → udata-11.1.1.dist-info}/top_level.txt +0 -0
udata/__init__.py
CHANGED
udata/core/topic/models.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from blinker import Signal
|
|
2
2
|
from flask import url_for
|
|
3
|
+
from mongoengine.errors import DoesNotExist
|
|
3
4
|
from mongoengine.signals import post_delete, post_save
|
|
4
5
|
|
|
5
6
|
from udata.api_fields import field
|
|
@@ -47,8 +48,12 @@ class TopicElement(Auditable, db.Document):
|
|
|
47
48
|
@classmethod
|
|
48
49
|
def post_delete(cls, sender, document, **kwargs):
|
|
49
50
|
"""Trigger reindex when element is deleted"""
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
try:
|
|
52
|
+
if document.topic and document.element and hasattr(document.element, "id"):
|
|
53
|
+
reindex.delay(*as_task_param(document.element))
|
|
54
|
+
except DoesNotExist:
|
|
55
|
+
# Topic might have been deleted, causing dereferencing to fail
|
|
56
|
+
pass
|
|
52
57
|
cls.on_delete.send(document)
|
|
53
58
|
|
|
54
59
|
|
|
@@ -86,6 +91,11 @@ class Topic(db.Datetimed, Auditable, Linkable, db.Document, Owned):
|
|
|
86
91
|
on_create = Signal()
|
|
87
92
|
on_update = Signal()
|
|
88
93
|
|
|
94
|
+
@classmethod
|
|
95
|
+
def post_delete(cls, sender, document, **kwargs):
|
|
96
|
+
"""Delete associated TopicElements when a Topic is deleted"""
|
|
97
|
+
TopicElement.objects(topic=document).delete()
|
|
98
|
+
|
|
89
99
|
def __str__(self):
|
|
90
100
|
return self.name
|
|
91
101
|
|
|
@@ -126,4 +136,5 @@ class Topic(db.Datetimed, Auditable, Linkable, db.Document, Owned):
|
|
|
126
136
|
|
|
127
137
|
post_save.connect(Topic.post_save, sender=Topic)
|
|
128
138
|
post_save.connect(TopicElement.post_save, sender=TopicElement)
|
|
139
|
+
post_delete.connect(Topic.post_delete, sender=Topic)
|
|
129
140
|
post_delete.connect(TopicElement.post_delete, sender=TopicElement)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Delete TopicElements that are not associated with an existing Topic
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
|
|
7
|
+
import mongoengine
|
|
8
|
+
|
|
9
|
+
from udata.core.topic.models import TopicElement
|
|
10
|
+
|
|
11
|
+
log = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def migrate(db):
|
|
15
|
+
log.info("Processing orphaned TopicElements...")
|
|
16
|
+
|
|
17
|
+
topic_elements = TopicElement.objects.no_cache().all()
|
|
18
|
+
deleted_count = 0
|
|
19
|
+
|
|
20
|
+
for element in topic_elements:
|
|
21
|
+
try:
|
|
22
|
+
# Try to access the topic - will raise DoesNotExist if topic was deleted
|
|
23
|
+
if element.topic:
|
|
24
|
+
_ = element.topic.id
|
|
25
|
+
except mongoengine.errors.DoesNotExist:
|
|
26
|
+
# Topic doesn't exist, delete the orphaned element
|
|
27
|
+
element.delete()
|
|
28
|
+
deleted_count += 1
|
|
29
|
+
|
|
30
|
+
log.info(f"Deleted {deleted_count} orphaned TopicElements")
|