udata 9.0.1.dev29632__py2.py3-none-any.whl → 9.0.1.dev29667__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/api/__init__.py +1 -0
- udata/core/topic/models.py +3 -2
- udata/core/topic/parsers.py +3 -2
- udata/core/user/apiv2.py +28 -0
- udata/tests/apiv2/test_me_api.py +40 -0
- {udata-9.0.1.dev29632.dist-info → udata-9.0.1.dev29667.dist-info}/METADATA +3 -2
- {udata-9.0.1.dev29632.dist-info → udata-9.0.1.dev29667.dist-info}/RECORD +11 -9
- {udata-9.0.1.dev29632.dist-info → udata-9.0.1.dev29667.dist-info}/LICENSE +0 -0
- {udata-9.0.1.dev29632.dist-info → udata-9.0.1.dev29667.dist-info}/WHEEL +0 -0
- {udata-9.0.1.dev29632.dist-info → udata-9.0.1.dev29667.dist-info}/entry_points.txt +0 -0
- {udata-9.0.1.dev29632.dist-info → udata-9.0.1.dev29667.dist-info}/top_level.txt +0 -0
udata/api/__init__.py
CHANGED
|
@@ -323,6 +323,7 @@ def init_app(app):
|
|
|
323
323
|
import udata.core.activity.api # noqa
|
|
324
324
|
import udata.core.spatial.api # noqa
|
|
325
325
|
import udata.core.user.api # noqa
|
|
326
|
+
import udata.core.user.apiv2 # noqa
|
|
326
327
|
import udata.core.dataset.api # noqa
|
|
327
328
|
import udata.core.dataset.apiv2 # noqa
|
|
328
329
|
import udata.core.dataservices.api # noqa
|
udata/core/topic/models.py
CHANGED
|
@@ -3,7 +3,7 @@ from mongoengine.signals import pre_save
|
|
|
3
3
|
from udata.models import db, SpatialCoverage
|
|
4
4
|
from udata.search import reindex
|
|
5
5
|
from udata.tasks import as_task_param
|
|
6
|
-
from udata.core.owned import Owned
|
|
6
|
+
from udata.core.owned import Owned, OwnedQuerySet
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
__all__ = ('Topic', )
|
|
@@ -36,7 +36,8 @@ class Topic(db.Document, Owned, db.Datetimed):
|
|
|
36
36
|
'slug'
|
|
37
37
|
] + Owned.meta['indexes'],
|
|
38
38
|
'ordering': ['-created_at'],
|
|
39
|
-
'auto_create_index_on_save': True
|
|
39
|
+
'auto_create_index_on_save': True,
|
|
40
|
+
'queryset_class': OwnedQuerySet,
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
def __str__(self):
|
udata/core/topic/parsers.py
CHANGED
|
@@ -11,10 +11,11 @@ class TopicApiParser(ModelApiParser):
|
|
|
11
11
|
'last_modified': 'last_modified',
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
def __init__(self):
|
|
14
|
+
def __init__(self, with_include_private=True):
|
|
15
15
|
super().__init__()
|
|
16
|
+
if with_include_private:
|
|
17
|
+
self.parser.add_argument('include_private', type=bool, location='args')
|
|
16
18
|
self.parser.add_argument('tag', type=str, location='args')
|
|
17
|
-
self.parser.add_argument('include_private', type=bool, location='args')
|
|
18
19
|
self.parser.add_argument('geozone', type=str, location='args')
|
|
19
20
|
self.parser.add_argument('granularity', type=str, location='args')
|
|
20
21
|
self.parser.add_argument('organization', type=str, location='args')
|
udata/core/user/apiv2.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from flask_security import current_user
|
|
2
|
+
|
|
3
|
+
from udata.api import apiv2, API
|
|
4
|
+
from udata.core.topic.apiv2 import topic_page_fields
|
|
5
|
+
from udata.core.topic.parsers import TopicApiParser
|
|
6
|
+
from udata.models import Topic
|
|
7
|
+
|
|
8
|
+
me = apiv2.namespace('me', 'Connected user related operations (v2)')
|
|
9
|
+
|
|
10
|
+
# we will force include_private to True, no need for this arg
|
|
11
|
+
topic_parser = TopicApiParser(with_include_private=False)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@me.route('/org_topics/', endpoint='my_org_topics')
|
|
15
|
+
class MyOrgTopicsAPI(API):
|
|
16
|
+
@apiv2.secure
|
|
17
|
+
@apiv2.doc('my_org_topics')
|
|
18
|
+
@apiv2.expect(topic_parser.parser)
|
|
19
|
+
@apiv2.marshal_list_with(topic_page_fields)
|
|
20
|
+
def get(self):
|
|
21
|
+
'''List all topics related to me and my organizations.'''
|
|
22
|
+
args = topic_parser.parse()
|
|
23
|
+
args["include_private"] = True
|
|
24
|
+
owners = list(current_user.organizations) + [current_user.id]
|
|
25
|
+
topics = Topic.objects.owned_by(*owners)
|
|
26
|
+
topics = topic_parser.parse_filters(topics, args)
|
|
27
|
+
sort = args['sort'] or ('$text_score' if args['q'] else None) or '-last-modified'
|
|
28
|
+
return topics.order_by(sort).paginate(args['page'], args['page_size'])
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from flask import url_for
|
|
2
|
+
|
|
3
|
+
from udata.models import Member
|
|
4
|
+
from udata.core.organization.factories import OrganizationFactory
|
|
5
|
+
from udata.core.topic.factories import TopicFactory
|
|
6
|
+
from udata.tests.api import APITestCase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MeAPIv2Test(APITestCase):
|
|
10
|
+
modules = []
|
|
11
|
+
|
|
12
|
+
def test_my_org_topics(self):
|
|
13
|
+
user = self.login()
|
|
14
|
+
member = Member(user=user, role='editor')
|
|
15
|
+
organization = OrganizationFactory(members=[member])
|
|
16
|
+
topics = [
|
|
17
|
+
TopicFactory(organization=organization, private=False, tags=['energy']),
|
|
18
|
+
TopicFactory(organization=organization, private=True),
|
|
19
|
+
TopicFactory(owner=user),
|
|
20
|
+
]
|
|
21
|
+
# another topic that shouldn't pop up
|
|
22
|
+
TopicFactory()
|
|
23
|
+
|
|
24
|
+
response = self.get(url_for('apiv2.my_org_topics'))
|
|
25
|
+
assert response.status_code == 200
|
|
26
|
+
data = response.json['data']
|
|
27
|
+
assert len(data) == 3
|
|
28
|
+
assert all(
|
|
29
|
+
str(topic.id) in [remote_topic["id"] for remote_topic in data]
|
|
30
|
+
for topic in topics
|
|
31
|
+
)
|
|
32
|
+
assert 'rel' in data[0]['datasets']
|
|
33
|
+
|
|
34
|
+
# topic parser is already tested in topics test
|
|
35
|
+
# we're just making sure one of theme is working
|
|
36
|
+
response = self.get(url_for('apiv2.my_org_topics', tag='energy'))
|
|
37
|
+
assert response.status_code == 200
|
|
38
|
+
data = response.json['data']
|
|
39
|
+
assert len(data) == 1
|
|
40
|
+
assert data[0]['id'] == str(topics[0].id)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 9.0.1.
|
|
3
|
+
Version: 9.0.1.dev29667
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -147,6 +147,7 @@ It is collectively taken care of by members of the
|
|
|
147
147
|
- Improve URL validation errors [#3063](https://github.com/opendatateam/udata/pull/3063) [#2768](https://github.com/opendatateam/udata/pull/2768)
|
|
148
148
|
- Do not return full dataset objects on dataservices endpoints [#3068](https://github.com/opendatateam/udata/pull/3068)
|
|
149
149
|
- Update markdown base settings [#3067](https://github.com/opendatateam/udata/pull/3067)
|
|
150
|
+
- Add api endpoint /me/org_topics/ [#3070](https://github.com/opendatateam/udata/pull/3070)
|
|
150
151
|
|
|
151
152
|
## 9.0.0 (2024-06-07)
|
|
152
153
|
|
|
@@ -166,7 +167,7 @@ It is collectively taken care of by members of the
|
|
|
166
167
|
- Allow for series in CSW ISO 19139 DCAT backend [#3028](https://github.com/opendatateam/udata/pull/3028)
|
|
167
168
|
- Add `email` to membership request list API response, add `since` to org members API responses, add `email` to members of org on show org endpoint for org's admins and editors [#3038](https://github.com/opendatateam/udata/pull/3038)
|
|
168
169
|
- Add `resources_downloads` to datasets metrics [#3042](https://github.com/opendatateam/udata/pull/3042)
|
|
169
|
-
- Fix do not override resources extras on admin during update [#3043](https://github.com/opendatateam/udata/pull/3043)
|
|
170
|
+
- Fix do not override resources extras on admin during update [#3043](https://github.com/opendatateam/udata/pull/3043)
|
|
170
171
|
- Endpoint /users is now protected by admin permissions [#3047](https://github.com/opendatateam/udata/pull/3047)
|
|
171
172
|
- Fix trailing `/` inside `GeoZone` routes not redirecting. Disallow `/` inside `GeoZone` ids [#3045](https://github.com/opendatateam/udata/pull/3045)
|
|
172
173
|
|
|
@@ -24,7 +24,7 @@ udata/worker.py,sha256=K-Wafye5-uXP4kQlffRKws2J9YbJ6m6n2QjcVsY8Nsg,118
|
|
|
24
24
|
udata/wsgi.py,sha256=P7AJvZ5JqY4uRSBOzaFiBniChWIU9RVQ-Y0PN4vCCMY,77
|
|
25
25
|
udata/admin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
udata/admin/views.py,sha256=wMlpnC1aINW-6JDk6-kQXhcTYBZH-5wajEuWzVDcIKA,331
|
|
27
|
-
udata/api/__init__.py,sha256=
|
|
27
|
+
udata/api/__init__.py,sha256=RhgO7r6ROJzhEybCDmtHRwIiUpE-LjEIUr7dRmNdSeg,11429
|
|
28
28
|
udata/api/commands.py,sha256=oK2p1VdUvULDdYuvYYpYvY_bdkPJy-KfROfoX71oOuA,3277
|
|
29
29
|
udata/api/errors.py,sha256=Sy_f3WVrNTUPZjCOogIVgocDdUjnKz149KDi4mMA_Lg,240
|
|
30
30
|
udata/api/fields.py,sha256=l-Fa27-easR86qgof2bk130jq1N1pNUgGmQzok1UI3Q,3094
|
|
@@ -221,13 +221,14 @@ udata/core/topic/api.py,sha256=G3hN4e9rK5mIYvDLvPpAOo_DN2SySAGykVVvXGx4uMY,5105
|
|
|
221
221
|
udata/core/topic/apiv2.py,sha256=cf-WUSZ7P6Tss3S8utS-uhreLgGI5XR3nn_1UWiZ_Xs,9846
|
|
222
222
|
udata/core/topic/factories.py,sha256=ksWcIAoYiKCS48q2-RKMYbNJfz1z9H0fBYM9lswFr-8,717
|
|
223
223
|
udata/core/topic/forms.py,sha256=XqGI4nANdsm2UkIiGAuVqEdZkN5N9sqJ4VaM_PhTaVQ,987
|
|
224
|
-
udata/core/topic/models.py,sha256=
|
|
225
|
-
udata/core/topic/parsers.py,sha256=
|
|
224
|
+
udata/core/topic/models.py,sha256=MOBrUNJ32r9Avsz1ueuF5DW3UEHIvxDyMUyxc8II-ig,2157
|
|
225
|
+
udata/core/topic/parsers.py,sha256=4fOvUA5wE9NBtq8liF_mnsgF7obCsfPNzNpgc-tnQf0,2167
|
|
226
226
|
udata/core/topic/permissions.py,sha256=RtFPPlxuU_Bv7ip6LDO4AoPrKFnIOEs9cCMXaSSmEdk,118
|
|
227
227
|
udata/core/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
228
228
|
udata/core/user/activities.py,sha256=AMRbYgum8uJXAS3L-ddQN-xKtKRvsmesDZ0ItBY_jS0,2799
|
|
229
229
|
udata/core/user/api.py,sha256=ngVaVv17Jwrd4sv1Vp4FduSRan5wv2mOP9y43xWbjPk,12781
|
|
230
230
|
udata/core/user/api_fields.py,sha256=aWw-vaLy5KqE8vr6HtWzoAbzHI8aoi9BV-m-oY7FJfo,5052
|
|
231
|
+
udata/core/user/apiv2.py,sha256=j9qOqoQw5OQvRy84xcOHtf_SJqbpFwmE0OVdPWGwxjg,1125
|
|
231
232
|
udata/core/user/commands.py,sha256=DlNBFaojhhPHH4kZazp0NMwYWnzPZXBba_vqH-cfR1U,3156
|
|
232
233
|
udata/core/user/constants.py,sha256=aTluhTR2RGZ_cdG7-mkEoT5Ndbg8BNUwwzCOld0aLMY,77
|
|
233
234
|
udata/core/user/factories.py,sha256=JiY-AghapelwhAVAExiUEHS1odyIu4PppWuhtZnkjBY,790
|
|
@@ -607,6 +608,7 @@ udata/tests/api/test_transfer_api.py,sha256=aGGJp79YYHQQyMAKhp7urk4eD587v3kbIy-8
|
|
|
607
608
|
udata/tests/api/test_user_api.py,sha256=IWMonc6qAsUVAGkxb-FqnwPSO6dGNsdS3c8rLwXvGEA,14659
|
|
608
609
|
udata/tests/apiv2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
609
610
|
udata/tests/apiv2/test_datasets.py,sha256=QDebrTdElry2yf3icjpo7FPm183U2vscHLpZrfap_3Y,18420
|
|
611
|
+
udata/tests/apiv2/test_me_api.py,sha256=GjreAZfH3-j-yDgDqNrtPolUPAiqs_OJVtrQUkMm3Ww,1430
|
|
610
612
|
udata/tests/apiv2/test_organizations.py,sha256=CpNG8xl13rZXxTN2-JRx9ZkyI7IuQUaOsNuumUxuB3I,6704
|
|
611
613
|
udata/tests/apiv2/test_swagger.py,sha256=D8jpRqDUmqVkNVYkYaXfvMPUc7OBVs_dMsC13KZciWE,785
|
|
612
614
|
udata/tests/apiv2/test_topics.py,sha256=UA5LcILq7zUa9TXi1iplrvtcY5C0u-0R8PvTCUWPs2Q,10106
|
|
@@ -688,9 +690,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=iAUNwbI8ESi8MHkE3ZCYCSIXfFC27z
|
|
|
688
690
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=uTmbHfzyFWrVXUkKSuNFzbGpX7EkUuBdD8fE04d3v5g,44572
|
|
689
691
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=1MbQHvKKNUwzMBWLNsH1qqBehO3aILhQiMhi5u1bY8E,28553
|
|
690
692
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=AAryt27Gbkhk7FntCCU8_e7HSXATfsAQhwFOFC8CAj0,51152
|
|
691
|
-
udata-9.0.1.
|
|
692
|
-
udata-9.0.1.
|
|
693
|
-
udata-9.0.1.
|
|
694
|
-
udata-9.0.1.
|
|
695
|
-
udata-9.0.1.
|
|
696
|
-
udata-9.0.1.
|
|
693
|
+
udata-9.0.1.dev29667.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
694
|
+
udata-9.0.1.dev29667.dist-info/METADATA,sha256=jRGiYzGgQ4kjdR658hbqRitIq0Fl3XwiPfcKbR_eXmI,125149
|
|
695
|
+
udata-9.0.1.dev29667.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
|
|
696
|
+
udata-9.0.1.dev29667.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
|
|
697
|
+
udata-9.0.1.dev29667.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
698
|
+
udata-9.0.1.dev29667.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|