udata 9.2.2.dev31569__py2.py3-none-any.whl → 9.2.2.dev31595__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 +24 -1
- udata/static/chunks/{5.4e4ddeee32090f1f2af6.js → 5.9049c2001a2f21930f78.js} +3 -3
- udata/static/chunks/{5.4e4ddeee32090f1f2af6.js.map → 5.9049c2001a2f21930f78.js.map} +1 -1
- udata/static/chunks/{6.41b17f3ca439d5ec2b1e.js → 6.ad092769b0983a6eec2a.js} +3 -3
- udata/static/chunks/{6.41b17f3ca439d5ec2b1e.js.map → 6.ad092769b0983a6eec2a.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/test_discussions.py +61 -0
- {udata-9.2.2.dev31569.dist-info → udata-9.2.2.dev31595.dist-info}/METADATA +2 -2
- {udata-9.2.2.dev31569.dist-info → udata-9.2.2.dev31595.dist-info}/RECORD +14 -14
- {udata-9.2.2.dev31569.dist-info → udata-9.2.2.dev31595.dist-info}/LICENSE +0 -0
- {udata-9.2.2.dev31569.dist-info → udata-9.2.2.dev31595.dist-info}/WHEEL +0 -0
- {udata-9.2.2.dev31569.dist-info → udata-9.2.2.dev31595.dist-info}/entry_points.txt +0 -0
- {udata-9.2.2.dev31569.dist-info → udata-9.2.2.dev31595.dist-info}/top_level.txt +0 -0
udata/core/discussions/api.py
CHANGED
|
@@ -6,6 +6,10 @@ from flask_security import current_user
|
|
|
6
6
|
|
|
7
7
|
from udata.api import API, api, fields
|
|
8
8
|
from udata.auth import admin_permission
|
|
9
|
+
from udata.core.dataservices.models import Dataservice
|
|
10
|
+
from udata.core.dataset.models import Dataset
|
|
11
|
+
from udata.core.organization.models import Organization
|
|
12
|
+
from udata.core.reuse.models import Reuse
|
|
9
13
|
from udata.core.spam.api import SpamAPIMixin
|
|
10
14
|
from udata.core.spam.fields import spam_fields
|
|
11
15
|
from udata.core.user.api_fields import user_ref_fields
|
|
@@ -73,8 +77,15 @@ comment_discussion_fields = api.model(
|
|
|
73
77
|
discussion_page_fields = api.model("DiscussionPage", fields.pager(discussion_fields))
|
|
74
78
|
|
|
75
79
|
parser = api.parser()
|
|
80
|
+
sorting_keys: list[str] = ["created", "title", "closed"]
|
|
81
|
+
sorting_choices: list[str] = sorting_keys + ["-" + k for k in sorting_keys]
|
|
76
82
|
parser.add_argument(
|
|
77
|
-
"sort",
|
|
83
|
+
"sort",
|
|
84
|
+
type=str,
|
|
85
|
+
default="-created",
|
|
86
|
+
choices=sorting_choices,
|
|
87
|
+
location="args",
|
|
88
|
+
help="The field (and direction) on which sorting apply",
|
|
78
89
|
)
|
|
79
90
|
parser.add_argument(
|
|
80
91
|
"closed",
|
|
@@ -85,6 +96,9 @@ parser.add_argument(
|
|
|
85
96
|
parser.add_argument(
|
|
86
97
|
"for", type=str, location="args", action="append", help="Filter discussions for a given subject"
|
|
87
98
|
)
|
|
99
|
+
parser.add_argument(
|
|
100
|
+
"org", type=str, location="args", help="Filter discussions for a given organization"
|
|
101
|
+
)
|
|
88
102
|
parser.add_argument("user", type=str, location="args", help="Filter discussions created by a user")
|
|
89
103
|
parser.add_argument("page", type=int, default=1, location="args", help="The page to fetch")
|
|
90
104
|
parser.add_argument(
|
|
@@ -198,6 +212,15 @@ class DiscussionsAPI(API):
|
|
|
198
212
|
discussions = Discussion.objects
|
|
199
213
|
if args["for"]:
|
|
200
214
|
discussions = discussions.generic_in(subject=args["for"])
|
|
215
|
+
if args["org"]:
|
|
216
|
+
org = Organization.objects.get_or_404(id=id_or_404(args["org"]))
|
|
217
|
+
if not org:
|
|
218
|
+
api.abort(404, "Organization does not exist")
|
|
219
|
+
reuses = Reuse.objects(organization=org).only("id")
|
|
220
|
+
datasets = Dataset.objects(organization=org).only("id")
|
|
221
|
+
dataservices = Dataservice.objects(organization=org).only("id")
|
|
222
|
+
subjects = list(reuses) + list(datasets) + list(dataservices)
|
|
223
|
+
discussions = discussions(subject__in=subjects)
|
|
201
224
|
if args["user"]:
|
|
202
225
|
discussions = discussions(discussion__posted_by=ObjectId(args["user"]))
|
|
203
226
|
if args["closed"] is False:
|