udata 10.4.2.dev35319__py2.py3-none-any.whl → 10.4.2.dev35397__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.

@@ -4,6 +4,7 @@ from bson import ObjectId
4
4
  from mongoengine.errors import DoesNotExist
5
5
 
6
6
  from udata.api import API, api, fields
7
+ from udata.auth import current_user
7
8
  from udata.core.organization.api_fields import org_ref_fields
8
9
  from udata.core.user.api_fields import user_ref_fields
9
10
  from udata.models import Activity, db
@@ -77,7 +78,7 @@ class SiteActivityAPI(API):
77
78
  @api.expect(activity_parser)
78
79
  @api.marshal_with(activity_page_fields)
79
80
  def get(self):
80
- """Fetch site activity, optionally filtered by user of org."""
81
+ """Fetch site activity, optionally filtered by user or org."""
81
82
  args = activity_parser.parse_args()
82
83
  qs = Activity.objects
83
84
 
@@ -96,10 +97,11 @@ class SiteActivityAPI(API):
96
97
  qs = qs.order_by("-created_at")
97
98
  qs = qs.paginate(args["page"], args["page_size"])
98
99
 
99
- # Filter out DBRefs
100
+ # - Filter out DBRefs
100
101
  # Always return a result even not complete
101
102
  # But log the error (ie. visible in sentry, silent for user)
102
103
  # Can happen when someone manually delete an object in DB (ie. without proper purge)
104
+ # - Filter out private items (except for sysadmin users)
103
105
  safe_items = []
104
106
  for item in qs.queryset.items:
105
107
  try:
@@ -107,6 +109,11 @@ class SiteActivityAPI(API):
107
109
  except DoesNotExist as e:
108
110
  log.error(e, exc_info=True)
109
111
  else:
112
+ if hasattr(item.related_to, "private") and (
113
+ current_user.is_anonymous or not current_user.sysadmin
114
+ ):
115
+ if item.related_to.private:
116
+ continue
110
117
  safe_items.append(item)
111
118
  qs.queryset.items = safe_items
112
119
 
@@ -36,18 +36,18 @@ class UserDeletedDataservice(DataserviceRelatedActivity, Activity):
36
36
 
37
37
  @Dataservice.on_create.connect
38
38
  def on_user_created_dataservice(dataservice):
39
- if not dataservice.private and current_user and current_user.is_authenticated:
39
+ if current_user and current_user.is_authenticated:
40
40
  UserCreatedDataservice.emit(dataservice, dataservice.organization)
41
41
 
42
42
 
43
43
  @Dataservice.on_update.connect
44
44
  def on_user_updated_dataservice(dataservice, **kwargs):
45
45
  changed_fields = kwargs.get("changed_fields", [])
46
- if not dataservice.private and current_user and current_user.is_authenticated:
46
+ if current_user and current_user.is_authenticated:
47
47
  UserUpdatedDataservice.emit(dataservice, dataservice.organization, changed_fields)
48
48
 
49
49
 
50
50
  @Dataservice.on_delete.connect
51
51
  def on_user_deleted_dataservice(dataservice):
52
- if not dataservice.private and current_user and current_user.is_authenticated:
52
+ if current_user and current_user.is_authenticated:
53
53
  UserDeletedDataservice.emit(dataservice, dataservice.organization)
@@ -55,7 +55,7 @@ class UserRemovedResourceFromDataset(DatasetRelatedActivity, Activity):
55
55
 
56
56
  @Dataset.on_resource_added.connect
57
57
  def on_user_added_resource_to_dataset(sender, document, **kwargs):
58
- if not document.private and current_user and current_user.is_authenticated:
58
+ if current_user and current_user.is_authenticated:
59
59
  UserAddedResourceToDataset.emit(
60
60
  document, document.organization, None, {"resource_id": str(kwargs["resource_id"])}
61
61
  )
@@ -64,7 +64,7 @@ def on_user_added_resource_to_dataset(sender, document, **kwargs):
64
64
  @Dataset.on_resource_updated.connect
65
65
  def on_user_updated_resource(sender, document, **kwargs):
66
66
  changed_fields = kwargs.get("changed_fields", [])
67
- if not document.private and current_user and current_user.is_authenticated:
67
+ if current_user and current_user.is_authenticated:
68
68
  UserUpdatedResource.emit(
69
69
  document,
70
70
  document.organization,
@@ -75,7 +75,7 @@ def on_user_updated_resource(sender, document, **kwargs):
75
75
 
76
76
  @Dataset.on_resource_removed.connect
77
77
  def on_user_removed_resource_from_dataset(sender, document, **kwargs):
78
- if not document.private and current_user and current_user.is_authenticated:
78
+ if current_user and current_user.is_authenticated:
79
79
  UserRemovedResourceFromDataset.emit(
80
80
  document, document.organization, None, {"resource_id": str(kwargs["resource_id"])}
81
81
  )
@@ -83,18 +83,18 @@ def on_user_removed_resource_from_dataset(sender, document, **kwargs):
83
83
 
84
84
  @Dataset.on_create.connect
85
85
  def on_user_created_dataset(dataset):
86
- if not dataset.private and current_user and current_user.is_authenticated:
86
+ if current_user and current_user.is_authenticated:
87
87
  UserCreatedDataset.emit(dataset, dataset.organization)
88
88
 
89
89
 
90
90
  @Dataset.on_update.connect
91
91
  def on_user_updated_dataset(dataset, **kwargs):
92
92
  changed_fields = kwargs.get("changed_fields", [])
93
- if not dataset.private and current_user and current_user.is_authenticated:
93
+ if current_user and current_user.is_authenticated:
94
94
  UserUpdatedDataset.emit(dataset, dataset.organization, changed_fields)
95
95
 
96
96
 
97
97
  @Dataset.on_delete.connect
98
98
  def on_user_deleted_dataset(dataset):
99
- if not dataset.private and current_user and current_user.is_authenticated:
99
+ if current_user and current_user.is_authenticated:
100
100
  UserDeletedDataset.emit(dataset, dataset.organization)
udata/core/dataset/rdf.py CHANGED
@@ -769,7 +769,7 @@ def dataset_from_rdf(graph: Graph, dataset=None, node=None, remote_url_prefix: s
769
769
  # Support dct:abstract if dct:description is missing (sometimes used instead)
770
770
  description = d.value(DCT.description) or d.value(DCT.abstract)
771
771
  dataset.description = sanitize_html(description)
772
- dataset.frequency = frequency_from_rdf(d.value(DCT.accrualPeriodicity))
772
+ dataset.frequency = frequency_from_rdf(d.value(DCT.accrualPeriodicity)) or dataset.frequency
773
773
  roles = [ # Imbricated list of contact points for each role
774
774
  contact_points_from_rdf(d, rdf_entity, role, dataset)
775
775
  for rdf_entity, role in CONTACT_POINT_ENTITY_TO_ROLE.items()
@@ -33,18 +33,18 @@ class UserDeletedReuse(ReuseRelatedActivity, Activity):
33
33
 
34
34
  @Reuse.on_create.connect
35
35
  def on_user_created_reuse(reuse):
36
- if not reuse.private and current_user and current_user.is_authenticated:
36
+ if current_user and current_user.is_authenticated:
37
37
  UserCreatedReuse.emit(reuse, reuse.organization)
38
38
 
39
39
 
40
40
  @Reuse.on_update.connect
41
41
  def on_user_updated_reuse(reuse, **kwargs):
42
42
  changed_fields = kwargs.get("changed_fields", [])
43
- if not reuse.private and current_user and current_user.is_authenticated:
43
+ if current_user and current_user.is_authenticated:
44
44
  UserUpdatedReuse.emit(reuse, reuse.organization, changed_fields)
45
45
 
46
46
 
47
47
  @Reuse.on_delete.connect
48
48
  def on_user_deleted_reuse(reuse):
49
- if not reuse.private and current_user and current_user.is_authenticated:
49
+ if current_user and current_user.is_authenticated:
50
50
  UserDeletedReuse.emit(reuse, reuse.organization)
@@ -7,7 +7,7 @@ from udata.core.dataset.factories import DatasetFactory
7
7
  from udata.core.dataset.models import Dataset
8
8
  from udata.core.reuse.factories import ReuseFactory
9
9
  from udata.core.reuse.models import Reuse
10
- from udata.core.user.factories import UserFactory
10
+ from udata.core.user.factories import AdminFactory, UserFactory
11
11
  from udata.mongo import db
12
12
  from udata.tests.helpers import assert200, assert400
13
13
 
@@ -67,3 +67,31 @@ class ActivityAPITest:
67
67
  assert200(response)
68
68
  len(response.json["data"]) == 1
69
69
  assert response.json["data"][0]["related_to"] == reuse.title
70
+
71
+ def test_activity_api_list_with_private(self, api) -> None:
72
+ """It should fetch an activity list from the API"""
73
+ activities: list[Activity] = [
74
+ FakeDatasetActivity.objects.create(
75
+ actor=UserFactory(), related_to=DatasetFactory(private=True)
76
+ ),
77
+ FakeReuseActivity.objects.create(
78
+ actor=UserFactory(), related_to=ReuseFactory(private=True)
79
+ ),
80
+ ]
81
+
82
+ # Anonymised user won't see activities about private documents
83
+ response: TestResponse = api.get(url_for("api.activity"))
84
+ assert200(response)
85
+ assert len(response.json["data"]) == 0
86
+
87
+ # Lambda user won't see activities about private documents
88
+ api.login()
89
+ response: TestResponse = api.get(url_for("api.activity"))
90
+ assert200(response)
91
+ assert len(response.json["data"]) == 0
92
+
93
+ # Sysadmin user will see activities about private documents
94
+ api.login(AdminFactory())
95
+ response: TestResponse = api.get(url_for("api.activity"))
96
+ assert200(response)
97
+ assert len(response.json["data"]) == len(activities)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 10.4.2.dev35319
3
+ Version: 10.4.2.dev35397
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -142,8 +142,10 @@ It is collectively taken care of by members of the
142
142
  ## Current (in progress)
143
143
 
144
144
  - Add activities to dataservices and resources, add Auditable class to refactor improve code [#3308](https://github.com/opendatateam/udata/pull/3308)
145
+ - Store activities for private objects [#3328](https://github.com/opendatateam/udata/pull/3328)
145
146
  - Do not crash if file doesn't exists during resource deletion [#3323](https://github.com/opendatateam/udata/pull/3323)
146
147
  - Show user domain in suggest [#3324](https://github.com/opendatateam/udata/pull/3324)
148
+ - Keep the existing frequency if not found during harvesting [#3330](https://github.com/opendatateam/udata/pull/3330)
147
149
 
148
150
  ## 10.4.1 (2025-05-20)
149
151
 
@@ -57,7 +57,7 @@ udata/core/__init__.py,sha256=O7C9WWCXiLWnWPnPbFRszWhOmvRQiI4gD-5qkWvPGRo,385
57
57
  udata/core/csv.py,sha256=qeRtSQXPT5n5EoWZ3_XfnOTW7ITnEzzHctODPeX63Uk,8543
58
58
  udata/core/owned.py,sha256=OQT7wdk7dAqGvWDiJRVkKJxerDc9_Io910nvLmfBAVI,5561
59
59
  udata/core/activity/__init__.py,sha256=U4e1qgBwiz3Lc7lbhIji3p1WVGsUg5GftfDrxFZQu5Q,352
60
- udata/core/activity/api.py,sha256=ECDnqDlOeWXtjumPZKTyOWHY8mMQr7KFQTF-tbO3jss,3944
60
+ udata/core/activity/api.py,sha256=-2Vz5BiZ6302JDK0q1FXtuZvmTy6fyBU0DIWu1GRQ64,4283
61
61
  udata/core/activity/models.py,sha256=ipViQMB1UMgxd9nolueanEgOB31s9pihTqkDdfo11u4,3214
62
62
  udata/core/activity/signals.py,sha256=Io2A43as3yR-DZ5R3wzM_bTpn528pxWsZDUFZ9xtj2Y,191
63
63
  udata/core/activity/tasks.py,sha256=F3PY12dnpT5Z8VuYfuOyDP6VPKPJmq1Sm4lSiPfmUCA,1498
@@ -81,7 +81,7 @@ udata/core/contact_point/factories.py,sha256=YoW2PKKaemYO4lIy5MwpH36uXM_J3rE-Ihs
81
81
  udata/core/contact_point/forms.py,sha256=oBe1agSJFyx2QRgYzPRg2A7qVscaBTaKG4V-AyIwnF8,729
82
82
  udata/core/contact_point/models.py,sha256=Xqmqg7S13gcaKxiQT52WHeQEHTaUDDGIXInXyqNh4Po,854
83
83
  udata/core/dataservices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
- udata/core/dataservices/activities.py,sha256=0gYJACjhHThQyiXcLD2gX858QjepXu8EUM3nVEp656w,1703
84
+ udata/core/dataservices/activities.py,sha256=CJK9DAohrG70YZAedHk3UdyIlF9cLaYeV6TR-aHosOs,1619
85
85
  udata/core/dataservices/api.py,sha256=7jOn3Ug63-5wjXP0d_zL0whdCQeHG_eQ1Y-wNhUuPLM,7388
86
86
  udata/core/dataservices/apiv2.py,sha256=XIqJq58uLtxtt52iKYo7Fl0ZXv9Sz72uA7JIGwP8Qos,995
87
87
  udata/core/dataservices/constants.py,sha256=LBCTQ44YvjTZfQVbxFiovPxapAknSJNOZKjMP8WeFy4,351
@@ -94,7 +94,7 @@ udata/core/dataservices/search.py,sha256=Wsr51jU14D9NrNP3ELTc8swwtFb-dakgc55cDrt
94
94
  udata/core/dataservices/tasks.py,sha256=d2tG1l6u8-eUKUYBOgnCsQLbLmLgJXU-DOzZWhhL6Qg,897
95
95
  udata/core/dataset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
96
  udata/core/dataset/actions.py,sha256=mX6xox0PiMrbcAPZ3VZsI26rfM-ciYfEXxN6sqqImKA,1222
97
- udata/core/dataset/activities.py,sha256=FD5A16cCyPvMY5lEEtQX3ENlaA1pao5Et8FbbHPpLgg,3195
97
+ udata/core/dataset/activities.py,sha256=RtY06G6FiEMr8NY26kaYKCXwGdcGtBJv2U8kWgFTRxE,3048
98
98
  udata/core/dataset/api.py,sha256=jElQZuguc514Eb0cWdquEfosP1yB79hEQ52SV_SvLx8,33282
99
99
  udata/core/dataset/api_fields.py,sha256=SLuzWoPdMLPX28WQ9DRGUPKS27vlltiFeiTo6jXa55Q,17549
100
100
  udata/core/dataset/apiv2.py,sha256=YOCNqQh7_OODcrzqJqdAPc0CoB9vG0DVcFiJNl9yBwQ,20749
@@ -108,7 +108,7 @@ udata/core/dataset/forms.py,sha256=7KUxuFcEGT0MUe0cZCiZtsnZhvGgvEd68pe13NgeSMI,6
108
108
  udata/core/dataset/models.py,sha256=BiqwN1mLffc4_LqtQ6KcNK1BIh04cVKFhyOw3n3BIK8,41161
109
109
  udata/core/dataset/permissions.py,sha256=zXQ6kU-Ni3Pl5tDtat-ZPupug9InsNeCN7xRLc2Vcrc,1097
110
110
  udata/core/dataset/preview.py,sha256=IwCqiNTjjXbtA_SSKF52pwnzKKEz0GyYM95QNn2Dkog,2561
111
- udata/core/dataset/rdf.py,sha256=HkjzcWgq9AfPvUGMRI7-ufRrgnlfBmP8crbgRhg6Lz4,31789
111
+ udata/core/dataset/rdf.py,sha256=6aqoZajpmA2nciZsG1pGeJr0HKgdxjtuGWvk8xXjfUI,31810
112
112
  udata/core/dataset/search.py,sha256=E7LqHBnq3sMefvmLwTpiw-Ovem2a3NJswHesRjctboE,5627
113
113
  udata/core/dataset/signals.py,sha256=WN4sV-lJlNsRkhcnhoy0SYJvCoYmK_5QFYZd1u-h4gs,161
114
114
  udata/core/dataset/tasks.py,sha256=BHE79WLdY8bhGqXRBbqsXdHF5uHv3ZlsKW2A8OYoElc,9997
@@ -174,7 +174,7 @@ udata/core/reports/api.py,sha256=2xKsYC93V3md2ahkZs--O_0dTWQTicES5_9jbfER3hM,155
174
174
  udata/core/reports/constants.py,sha256=LRZSX3unyqZeB4yQjK3ws_hGbJcXYk4bu1Rhnhi5DEs,1235
175
175
  udata/core/reports/models.py,sha256=AsW5p2ZIdR4c6vNzglEN7MX03It-t9u7ktOsVZqvzSs,2702
176
176
  udata/core/reuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
177
- udata/core/reuse/activities.py,sha256=3eh3zS4eH_199rdwIW0vtrYdKAZ8W3qRbrt_CRLNZXY,1486
177
+ udata/core/reuse/activities.py,sha256=5D7cV-hGZnzHsp8hohZqqgK3RSGQpfAqJ_Wfq_AYfM8,1420
178
178
  udata/core/reuse/api.py,sha256=931cn6CGVcHv0XhSAXyjHkKy-9nOGHaHdE3uMU8v9mc,10928
179
179
  udata/core/reuse/api_fields.py,sha256=c61Gl56UjiBpXS0Nbvcoi_QHdUmhnBtqWm6nNHRYKyc,1232
180
180
  udata/core/reuse/apiv2.py,sha256=nZe-v8713aXKuv2B578NdxfrIckjbxhS3zUXAKSIKTI,835
@@ -622,7 +622,7 @@ udata/tests/test_transfer.py,sha256=_0pBwYs3T7OSZ7bO3KmQ81SjwCJyT4EVf8YYHXOkwdk,
622
622
  udata/tests/test_uris.py,sha256=MxafZ0SyzSNRomVpZnH1ChzWaHOi1MQiXe1gmKnBc6o,8517
623
623
  udata/tests/test_utils.py,sha256=3BGnlvw-GOE6tLHQteo-uUeYuzq4rsjePOuytFGkpOg,7967
624
624
  udata/tests/api/__init__.py,sha256=y4sL7LD1-KwONHF0q_Rhk2W6BmGUlp7Uz2JnX3e27sk,1218
625
- udata/tests/api/test_activities_api.py,sha256=RjDDeNle3T-ydVnh6BRypqxAE_244-DXaKkuUCT0HVU,2823
625
+ udata/tests/api/test_activities_api.py,sha256=WSBScq_gMaBJJchvmyoc_LnslXemgfvdDMtzgf8wDqg,3987
626
626
  udata/tests/api/test_auth_api.py,sha256=OMRlY0OQt60j5N4A-N3HdWTuffOjRlFHkz5a3jJFieI,25987
627
627
  udata/tests/api/test_base_api.py,sha256=2w_vz0eEuq3P3aN-ByvxGc3VZAo7XtgatFfcrzf2uEU,2244
628
628
  udata/tests/api/test_contact_points.py,sha256=X_RWD_xCfR8WchhHfKEt5mxMHY77OmTyguNKCsZftdE,5337
@@ -727,9 +727,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=ViV14tUmjSydHS0TWG_mFikKQfyUaT
727
727
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=rzAD_MVoV54TmN3w1ECz3H2Ru5pM7hWMVH03SkY28Q8,47250
728
728
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=EHX1_D-Uglj38832G7BrA0QC5IuY3p8dKqi9T0DgPmE,29169
729
729
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=3PMnbVhKVJh6Q8ABi1ZTZ8Dcf-sMjngLJZqLbonJoec,54225
730
- udata-10.4.2.dev35319.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
731
- udata-10.4.2.dev35319.dist-info/METADATA,sha256=Au8KhpPvrAdVMP-YYk8a1wOly-4_2_zAhZ1SoALR0V8,146838
732
- udata-10.4.2.dev35319.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
733
- udata-10.4.2.dev35319.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
734
- udata-10.4.2.dev35319.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
735
- udata-10.4.2.dev35319.dist-info/RECORD,,
730
+ udata-10.4.2.dev35397.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
731
+ udata-10.4.2.dev35397.dist-info/METADATA,sha256=CcVTBd3s795OqiP6v_xPJJC7uO20LFvmL0vtNN84afI,147052
732
+ udata-10.4.2.dev35397.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
733
+ udata-10.4.2.dev35397.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
734
+ udata-10.4.2.dev35397.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
735
+ udata-10.4.2.dev35397.dist-info/RECORD,,