udata 10.8.1.dev36640__py2.py3-none-any.whl → 10.8.1.dev36652__py2.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/core/discussions/api.py +6 -0
- udata/core/discussions/models.py +11 -1
- udata/tests/test_discussions.py +39 -0
- {udata-10.8.1.dev36640.dist-info → udata-10.8.1.dev36652.dist-info}/METADATA +2 -1
- {udata-10.8.1.dev36640.dist-info → udata-10.8.1.dev36652.dist-info}/RECORD +9 -9
- {udata-10.8.1.dev36640.dist-info → udata-10.8.1.dev36652.dist-info}/LICENSE +0 -0
- {udata-10.8.1.dev36640.dist-info → udata-10.8.1.dev36652.dist-info}/WHEEL +0 -0
- {udata-10.8.1.dev36640.dist-info → udata-10.8.1.dev36652.dist-info}/entry_points.txt +0 -0
- {udata-10.8.1.dev36640.dist-info → udata-10.8.1.dev36652.dist-info}/top_level.txt +0 -0
udata/core/discussions/api.py
CHANGED
|
@@ -130,6 +130,7 @@ discussion_page_fields = api.model("DiscussionPage", fields.pager(discussion_fie
|
|
|
130
130
|
parser = api.parser()
|
|
131
131
|
sorting_keys: list[str] = ["created", "title", "closed", "discussion.posted_on"]
|
|
132
132
|
sorting_choices: list[str] = sorting_keys + ["-" + k for k in sorting_keys]
|
|
133
|
+
parser.add_argument("q", type=str, location="args", help="The search query")
|
|
133
134
|
parser.add_argument(
|
|
134
135
|
"sort",
|
|
135
136
|
type=str,
|
|
@@ -331,6 +332,11 @@ class DiscussionsAPI(API):
|
|
|
331
332
|
discussions = discussions(closed=None)
|
|
332
333
|
elif args["closed"] is True:
|
|
333
334
|
discussions = discussions(closed__ne=None)
|
|
335
|
+
|
|
336
|
+
if args["q"]:
|
|
337
|
+
phrase_query = " ".join([f'"{elem}"' for elem in args["q"].split(" ")])
|
|
338
|
+
discussions = discussions.search_text(phrase_query).order_by("$text_score")
|
|
339
|
+
|
|
334
340
|
discussions = discussions.order_by(args["sort"])
|
|
335
341
|
return discussions.paginate(args["page"], args["page_size"])
|
|
336
342
|
|
udata/core/discussions/models.py
CHANGED
|
@@ -82,8 +82,18 @@ class Discussion(SpamMixin, Linkable, db.Document):
|
|
|
82
82
|
extras = db.ExtrasField()
|
|
83
83
|
|
|
84
84
|
meta = {
|
|
85
|
-
"indexes": [
|
|
85
|
+
"indexes": [
|
|
86
|
+
{
|
|
87
|
+
"fields": ["$title", "$discussion.content"],
|
|
88
|
+
"default_language": "french",
|
|
89
|
+
"weights": {"title": 10, "discussion.content": 5},
|
|
90
|
+
},
|
|
91
|
+
"user",
|
|
92
|
+
"subject",
|
|
93
|
+
"-created",
|
|
94
|
+
],
|
|
86
95
|
"ordering": ["-created"],
|
|
96
|
+
"auto_create_index_on_save": True,
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
@property
|
udata/tests/test_discussions.py
CHANGED
|
@@ -422,6 +422,45 @@ class DiscussionsTest(APITestCase):
|
|
|
422
422
|
|
|
423
423
|
self.assertEqual(len(response.json["data"]), len(discussions))
|
|
424
424
|
|
|
425
|
+
def test_list_discussions_search(self):
|
|
426
|
+
user = self.login()
|
|
427
|
+
dataset = DatasetFactory()
|
|
428
|
+
|
|
429
|
+
discussion_a = DiscussionFactory(
|
|
430
|
+
user=user,
|
|
431
|
+
subject=dataset,
|
|
432
|
+
title="discussion a",
|
|
433
|
+
discussion=[
|
|
434
|
+
Message(posted_by=user, content="another message"),
|
|
435
|
+
Message(posted_by=user, content="a message with something"),
|
|
436
|
+
],
|
|
437
|
+
)
|
|
438
|
+
discussion_b = DiscussionFactory(
|
|
439
|
+
user=user,
|
|
440
|
+
subject=dataset,
|
|
441
|
+
title="something in title",
|
|
442
|
+
discussion=[
|
|
443
|
+
Message(posted_by=user, content="another message"),
|
|
444
|
+
Message(posted_by=user, content="there is a problem"),
|
|
445
|
+
],
|
|
446
|
+
)
|
|
447
|
+
DiscussionFactory(
|
|
448
|
+
user=user,
|
|
449
|
+
subject=dataset,
|
|
450
|
+
title="discussion c",
|
|
451
|
+
discussion=[
|
|
452
|
+
Message(posted_by=user, content="some text"),
|
|
453
|
+
Message(posted_by=user, content="and another"),
|
|
454
|
+
],
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
response = self.get(url_for("api.discussions", q="something"))
|
|
458
|
+
self.assert200(response)
|
|
459
|
+
|
|
460
|
+
self.assertEqual(len(response.json["data"]), 2)
|
|
461
|
+
self.assertEqual(discussion_b.title, response.json["data"][0]["title"])
|
|
462
|
+
self.assertEqual(discussion_a.title, response.json["data"][1]["title"])
|
|
463
|
+
|
|
425
464
|
def assertIdIn(self, json_data: dict, id_: str) -> None:
|
|
426
465
|
for item in json_data:
|
|
427
466
|
if item["id"] == id_:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 10.8.1.
|
|
3
|
+
Version: 10.8.1.dev36652
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -142,6 +142,7 @@ It is collectively taken care of by members of the
|
|
|
142
142
|
|
|
143
143
|
## Current (in progress)
|
|
144
144
|
|
|
145
|
+
- Add search to discussions [#3384](https://github.com/opendatateam/udata/pull/3384)
|
|
145
146
|
- Separate metrics for opened discussions [#3370](https://github.com/opendatateam/udata/pull/3370)
|
|
146
147
|
|
|
147
148
|
## 10.8.0 (2025-07-22)
|
|
@@ -117,13 +117,13 @@ udata/core/dataset/tasks.py,sha256=6FzeLzJRQxzq7sBLUE8H8ZGLByix2EDOzGAsA8FteX8,1
|
|
|
117
117
|
udata/core/dataset/transport.py,sha256=ihCXirY1dZjOfXKbf9HRCJTfIOc75rM1McwbeGjsW6A,1296
|
|
118
118
|
udata/core/discussions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
119
119
|
udata/core/discussions/actions.py,sha256=kjdBLDIeu0yWTSxQGgOpN1WoxUqbMygn4SiBk_S9T5I,1051
|
|
120
|
-
udata/core/discussions/api.py,sha256=
|
|
120
|
+
udata/core/discussions/api.py,sha256=m2a_jLBL4dQejXfjjC3GJFpc-cDT32T8X6ka5LgwyPU,13259
|
|
121
121
|
udata/core/discussions/constants.py,sha256=8crl2Lmkv9dmJe4KACM0JJcpoHePmGtmvI6ixfvukhc,277
|
|
122
122
|
udata/core/discussions/csv.py,sha256=vIuMPJBrAOQmQ4P9SSY1wun0Av1qOE7i0TlQi-Vy7iU,772
|
|
123
123
|
udata/core/discussions/factories.py,sha256=CgQaUmmyDu90XtyBsqXVa-TmZMrN7Dwuu1Cnr5wNrVc,350
|
|
124
124
|
udata/core/discussions/forms.py,sha256=sR8tFBIBh-Rbx9VPzFzG1N54QY1y7UrdeboQ_60gXXQ,1265
|
|
125
125
|
udata/core/discussions/metrics.py,sha256=WMalLO9GEHXlqE2WbZX-HQUpvte6cRwuHuoL96QwWSg,354
|
|
126
|
-
udata/core/discussions/models.py,sha256=
|
|
126
|
+
udata/core/discussions/models.py,sha256=NrP_MjgTRMMJpa0d_vL28ElJUQ-J5l0Cs3qHxCsHzds,6202
|
|
127
127
|
udata/core/discussions/notifications.py,sha256=5MuoZDPmmvkloZ3i8I6TELgE1KXZ_cB9QiDerFBD9dM,1052
|
|
128
128
|
udata/core/discussions/permissions.py,sha256=VY2_PEsazz1fBgCX9-K-_spRgxUoNY4HuNDShqZjw6E,1583
|
|
129
129
|
udata/core/discussions/signals.py,sha256=tJ83RJIsBAny08Q6IDwehE6lDDRf6ynIFCl0WqnayoU,543
|
|
@@ -616,7 +616,7 @@ udata/tests/test_activity.py,sha256=x-pDK6VW9wAG0uxYRZQ3DWTRjfCU729iaMGMJb1rWYU,
|
|
|
616
616
|
udata/tests/test_api_fields.py,sha256=9ta1IU8GvmYof1Xg0Avvh0s5WF7-1VmW-fi2Vine99I,12273
|
|
617
617
|
udata/tests/test_cors.py,sha256=b_pyxKeIyqhnsXxXryPf4d0V0QxaLQ1P_VjY89Q_j3g,3233
|
|
618
618
|
udata/tests/test_dcat_commands.py,sha256=fDAnAjkja8AXw_qzaAWnVTgglkBAvK2mjPMHUCtqrrU,919
|
|
619
|
-
udata/tests/test_discussions.py,sha256=
|
|
619
|
+
udata/tests/test_discussions.py,sha256=a2yBGfOSm93w8zP2s2gXy51LGniiZ0lbrej0uuXNd2E,47685
|
|
620
620
|
udata/tests/test_i18n.py,sha256=u60344JNRG_8s0t89ghXtQ1FbF4TayEHBzuBFxqnQ_Y,3152
|
|
621
621
|
udata/tests/test_linkchecker.py,sha256=W8jrwKYXM8wWXZFjiaBwpWGRBhZ8bsSHGHzL9voDN7U,10218
|
|
622
622
|
udata/tests/test_mail.py,sha256=f-8meP9r1Xrz0eOTsvmdynoV9OFHLwwMr7XM5WWv_gk,4182
|
|
@@ -740,9 +740,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=9sCd1MUKvtVP_sOXvK-G5v4PfWkkdA
|
|
|
740
740
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=-eJptz9s63rjkdm-3HJi_2t70pyv3-8EuXBn-B2qI_4,48419
|
|
741
741
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=qduXntHWe__KaUxJ4JwwyGG3eSgYb1auGdNax0lS49c,29169
|
|
742
742
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=6QCuLMCRjgyAvu9U7i0P19ae8fm_uStfmxHLqUO9EoY,55394
|
|
743
|
-
udata-10.8.1.
|
|
744
|
-
udata-10.8.1.
|
|
745
|
-
udata-10.8.1.
|
|
746
|
-
udata-10.8.1.
|
|
747
|
-
udata-10.8.1.
|
|
748
|
-
udata-10.8.1.
|
|
743
|
+
udata-10.8.1.dev36652.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
744
|
+
udata-10.8.1.dev36652.dist-info/METADATA,sha256=P3IbXyLUIdt0AdS0kOAfPNTF4-FkICc9VjzclbGeHqs,151981
|
|
745
|
+
udata-10.8.1.dev36652.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
|
|
746
|
+
udata-10.8.1.dev36652.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
|
|
747
|
+
udata-10.8.1.dev36652.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
748
|
+
udata-10.8.1.dev36652.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|