udata 9.0.1.dev29625__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 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
@@ -140,7 +140,7 @@ class Dataservice(WithMetrics, Owned, db.Document):
140
140
  db.ListField(
141
141
  field(
142
142
  db.ReferenceField(Dataset),
143
- nested_fields=datasets_api_fields.dataset_fields,
143
+ nested_fields=datasets_api_fields.dataset_ref_fields,
144
144
  )
145
145
  ),
146
146
  filterable={
@@ -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):
@@ -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')
@@ -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.dev29625
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
@@ -145,7 +145,9 @@ It is collectively taken care of by members of the
145
145
  - Save and show harvest logs [#3053](https://github.com/opendatateam/udata/pull/3053)
146
146
  - Fix missing `ObjectId` validation on `/sources` endpoint [#3060](https://github.com/opendatateam/udata/pull/3060)
147
147
  - Improve URL validation errors [#3063](https://github.com/opendatateam/udata/pull/3063) [#2768](https://github.com/opendatateam/udata/pull/2768)
148
+ - Do not return full dataset objects on dataservices endpoints [#3068](https://github.com/opendatateam/udata/pull/3068)
148
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)
149
151
 
150
152
  ## 9.0.0 (2024-06-07)
151
153
 
@@ -165,7 +167,7 @@ It is collectively taken care of by members of the
165
167
  - Allow for series in CSW ISO 19139 DCAT backend [#3028](https://github.com/opendatateam/udata/pull/3028)
166
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)
167
169
  - Add `resources_downloads` to datasets metrics [#3042](https://github.com/opendatateam/udata/pull/3042)
168
- - 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)
169
171
  - Endpoint /users is now protected by admin permissions [#3047](https://github.com/opendatateam/udata/pull/3047)
170
172
  - Fix trailing `/` inside `GeoZone` routes not redirecting. Disallow `/` inside `GeoZone` ids [#3045](https://github.com/opendatateam/udata/pull/3045)
171
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=I40g3PLG4s-zGNQfjB8_KQGzfs3ZyUrZdajd20vQ9ks,11388
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
@@ -80,7 +80,7 @@ udata/core/contact_point/forms.py,sha256=ggLhSJ1IRn5MclrhydckjAxwr4fFZxgAD4huSSu
80
80
  udata/core/contact_point/models.py,sha256=NlNKureCpzgTLJuGviZPjNx-ABYRp4j2L-ur9Gmixao,324
81
81
  udata/core/dataservices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
82
  udata/core/dataservices/api.py,sha256=rjCU55NNGgCDRlurfhJUT2byBGJWN5coM8b7AApzEew,3090
83
- udata/core/dataservices/models.py,sha256=8hqBRlxvEbfu6PqRzhfceU3r-93Px0jgzNoixgTQBfs,5864
83
+ udata/core/dataservices/models.py,sha256=zMhzjnXm1p5GHZU1lYgMqft5u7iFyX0BIvNB1hM4D6Q,5868
84
84
  udata/core/dataservices/permissions.py,sha256=X9Bh8e0pnx6OgeEf6NowXZUiwyreUa6UY479B16cCqs,175
85
85
  udata/core/dataservices/rdf.py,sha256=TV02R2ZV_aDboSyl-4LJN1qG-5ibgrUYQZYmpl6Jqr4,2469
86
86
  udata/core/dataservices/tasks.py,sha256=NOWcTPoLasMrrvq9EkwQMGlUbQQmi_l3s815K-mtZTM,971
@@ -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=Fsq4ONTOhDkgNijhRHXqUAOwtqAcUbjanmjftXN5GNE,2100
225
- udata/core/topic/parsers.py,sha256=p2JCGfjeqb5GQTstZssclzLRLqUHy7KWJ7TDcLSF51M,2103
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.dev29625.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
692
- udata-9.0.1.dev29625.dist-info/METADATA,sha256=5iFQ5eGwqQr2AtgVLrJREIC6cVoa2tsnX4tkCNIaJE4,124938
693
- udata-9.0.1.dev29625.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
694
- udata-9.0.1.dev29625.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
695
- udata-9.0.1.dev29625.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
696
- udata-9.0.1.dev29625.dist-info/RECORD,,
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,,