udata 10.4.0__py2.py3-none-any.whl → 10.4.1__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/__init__.py CHANGED
@@ -4,5 +4,5 @@
4
4
  udata
5
5
  """
6
6
 
7
- __version__ = "10.4.0"
7
+ __version__ = "10.4.1"
8
8
  __description__ = "Open data portal"
@@ -191,7 +191,7 @@ dataset_fields = apiv2.model(
191
191
  spatial_coverage_fields, allow_null=True, description="The spatial coverage"
192
192
  ),
193
193
  "license": fields.Raw(
194
- attribute=lambda d: marshal(d.license, license_fields)
194
+ attribute=lambda d: marshal(d.license or DEFAULT_LICENSE, license_fields)
195
195
  if request.headers.get(FULL_OBJECTS_HEADER, False, bool)
196
196
  else (d.license.id if d.license is not None else None),
197
197
  default=DEFAULT_LICENSE["id"],
udata/core/dataset/csv.py CHANGED
@@ -40,7 +40,6 @@ class DatasetCsvAdapter(csv.Adapter):
40
40
  ("resources_count", lambda o: len(o.resources)),
41
41
  ("main_resources_count", lambda o: len([r for r in o.resources if r.type == "main"])),
42
42
  ("resources_formats", lambda o: ",".join(set(r.format for r in o.resources if r.format))),
43
- "downloads",
44
43
  ("harvest.backend", lambda r: r.harvest and r.harvest.backend),
45
44
  ("harvest.domain", lambda r: r.harvest and r.harvest.domain),
46
45
  ("harvest.created_at", lambda r: r.harvest and r.harvest.created_at),
@@ -897,10 +897,6 @@ class Dataset(WithMetrics, DatasetBadgeMixin, Owned, db.Document):
897
897
 
898
898
  return result
899
899
 
900
- @property
901
- def downloads(self):
902
- return sum(resource.metrics.get("views", 0) for resource in self.resources)
903
-
904
900
  @staticmethod
905
901
  def normalize_score(score):
906
902
  """
@@ -51,10 +51,14 @@ class FollowAPI(API):
51
51
  def get(self, id):
52
52
  """List all followers for a given object"""
53
53
  args = parser.parse_args()
54
- model = self.model.objects.only("id").get_or_404(id=id_or_404(id))
54
+ model = None
55
+ if hasattr(self.model, "slug"):
56
+ model = self.model.objects(slug=id).first()
57
+ model = model or self.model.objects.only("id").get_or_404(id=id_or_404(id))
55
58
  qs = Follow.objects(following=model, until=None)
56
59
  if args["user"]:
57
60
  qs = qs.filter(follower=id_or_404(args["user"]))
61
+
58
62
  return qs.paginate(args["page"], args["page_size"])
59
63
 
60
64
  @api.secure
@@ -58,7 +58,7 @@ class ReuseBadgeMixin(BadgeMixin):
58
58
  {"key": "views", "value": "metrics.views"},
59
59
  ],
60
60
  additional_filters={"organization_badge": "organization.badges"},
61
- mask="*,datasets{title,uri,page}",
61
+ mask="*,datasets{id,title,uri,page}",
62
62
  )
63
63
  class Reuse(db.Datetimed, WithMetrics, ReuseBadgeMixin, Owned, db.Document):
64
64
  title = field(
@@ -19,6 +19,8 @@ from udata.core.dataset.api_fields import (
19
19
  resource_harvest_fields,
20
20
  )
21
21
  from udata.core.dataset.constants import (
22
+ DEFAULT_FREQUENCY,
23
+ DEFAULT_LICENSE,
22
24
  FULL_OBJECTS_HEADER,
23
25
  LEGACY_FREQUENCIES,
24
26
  RESOURCE_TYPES,
@@ -512,6 +514,7 @@ class DatasetAPITest(APITestCase):
512
514
  license = LicenseFactory(id="lov2", title="Licence Ouverte Version 2.0")
513
515
  paca, bdr, arles = create_geozones_fixtures()
514
516
  country = GeoLevelFactory(id="country", name="Pays", admin_level=10)
517
+ other = GeoLevelFactory(id="other", name="Autre")
515
518
 
516
519
  dataset = DatasetFactory(
517
520
  frequency="monthly",
@@ -542,6 +545,27 @@ class DatasetAPITest(APITestCase):
542
545
  assert response.json["spatial"]["granularity"]["id"] == "country"
543
546
  assert response.json["spatial"]["granularity"]["name"] == country.name
544
547
 
548
+ dataset_without_anything = DatasetFactory(
549
+ frequency=None,
550
+ license=None,
551
+ spatial=SpatialCoverageFactory(zones=[], granularity=None),
552
+ )
553
+
554
+ response = self.get(
555
+ url_for("apiv2.dataset", dataset=dataset_without_anything),
556
+ headers={
557
+ FULL_OBJECTS_HEADER: "True",
558
+ },
559
+ )
560
+ self.assert200(response)
561
+ assert response.json["frequency"]["id"] == DEFAULT_FREQUENCY
562
+ assert response.json["frequency"]["label"] == UPDATE_FREQUENCIES.get(DEFAULT_FREQUENCY)
563
+ assert response.json["license"]["id"] == DEFAULT_LICENSE["id"]
564
+ assert response.json["license"]["title"] == DEFAULT_LICENSE["title"]
565
+ assert len(response.json["spatial"]["zones"]) == 0
566
+ assert response.json["spatial"]["granularity"]["id"] == "other"
567
+ assert response.json["spatial"]["granularity"]["name"] == other.name
568
+
545
569
  def test_dataset_api_create(self):
546
570
  """It should create a dataset from the API"""
547
571
  data = DatasetFactory.as_dict()
@@ -21,7 +21,10 @@ class DatasetCSVAdapterTest:
21
21
  "created_at": date_created,
22
22
  "modified_at": date_modified,
23
23
  "uri": "http://domain.gouv.fr/dataset/uri",
24
- }
24
+ },
25
+ metrics={
26
+ "views": 42,
27
+ },
25
28
  )
26
29
  ],
27
30
  harvest={
@@ -41,6 +44,8 @@ class DatasetCSVAdapterTest:
41
44
  assert date_modified.isoformat() in d_row
42
45
  # dataset harvest dates should not be here
43
46
  assert another_date.isoformat() not in d_row
47
+ # assert resource metrics downloads
48
+ assert 42 in d_row
44
49
 
45
50
  def test_datasets_csv_adapter(self):
46
51
  date_created = datetime(2022, 12, 31)
@@ -87,10 +92,8 @@ class DatasetCSVAdapterTest:
87
92
  assert harvest_dataset_values["harvest.domain"] == "example.com"
88
93
  assert harvest_dataset_values["harvest.remote_url"] == "https://www.example.com/"
89
94
  assert harvest_dataset_values["resources_count"] == 0
90
- assert harvest_dataset_values["downloads"] == 0
91
95
 
92
96
  resources_dataset_values = csv[str(resources_dataset.id)]
93
97
  assert resources_dataset_values["resources_count"] == 3
94
98
  assert resources_dataset_values["main_resources_count"] == 1
95
99
  assert set(resources_dataset_values["resources_formats"].split(",")) == set(["csv", "json"])
96
- assert resources_dataset_values["downloads"] == 1337 + 42
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: udata
3
- Version: 10.4.0
3
+ Version: 10.4.1
4
4
  Summary: Open data portal
5
5
  Home-page: https://github.com/opendatateam/udata
6
6
  Author: Opendata Team
@@ -139,6 +139,13 @@ It is collectively taken care of by members of the
139
139
 
140
140
  # Changelog
141
141
 
142
+ ## 10.4.1 (2025-05-20)
143
+
144
+ - Remove duplicate `downloads` in dataset csv adapter [#3319](https://github.com/opendatateam/udata/pull/3319)
145
+ - Add missing default for license full object [#3317](https://github.com/opendatateam/udata/pull/3317/)
146
+ - Check for slugs in followers API [#3320](https://github.com/opendatateam/udata/pull/3320)
147
+ - Fix missing ID in dataset reuses mask [#3321](https://github.com/opendatateam/udata/pull/3321)
148
+
142
149
  ## 10.4.0 (2025-05-15)
143
150
 
144
151
  - Improve reuse api perfs by adding a mask on datasets [#3309](https://github.com/opendatateam/udata/pull/3309)
@@ -1,6 +1,6 @@
1
1
  tasks/__init__.py,sha256=nfgZ5nkcoluXMIk52P4-8Rj6xL0Qlm_xSUfWW2aHZfI,8161
2
2
  tasks/helpers.py,sha256=70fS9tI_m0DTWmKx9Zl5-LG-nxdz_ZaPyvvsFkN2r48,1091
3
- udata/__init__.py,sha256=9s_K6HS4Auik4z8CvyR1lvvu0ik3M9VAnV8dF587kzs,98
3
+ udata/__init__.py,sha256=Q2Be4oLhN0_Vuj6mWi33jIAhlfhyEZrKXQnjwPr9VrQ,98
4
4
  udata/api_fields.py,sha256=nv_Nl1Mi-XQ8V08fxmscer13jsNNJgSOOIQEh1itsLQ,30679
5
5
  udata/app.py,sha256=xjk2D3EgboYBpTwBwdIxd2klt2yMoWMyCrkry5fz0LA,7292
6
6
  udata/assets.py,sha256=H5Hrc2vnKM0IFLyWfLXmJ2Kj35w1i8W1D8Cgy8_cUj4,657
@@ -96,15 +96,15 @@ udata/core/dataset/actions.py,sha256=mX6xox0PiMrbcAPZ3VZsI26rfM-ciYfEXxN6sqqImKA
96
96
  udata/core/dataset/activities.py,sha256=v8k1jwhdx62Z2ARZq8Q-x86OWSsBK99hRloPl74OCgA,1502
97
97
  udata/core/dataset/api.py,sha256=jElQZuguc514Eb0cWdquEfosP1yB79hEQ52SV_SvLx8,33282
98
98
  udata/core/dataset/api_fields.py,sha256=SLuzWoPdMLPX28WQ9DRGUPKS27vlltiFeiTo6jXa55Q,17549
99
- udata/core/dataset/apiv2.py,sha256=zrqln8hYxYgOJdorL-gDX67W8iVBKAn8YDYY9wAY00c,20730
99
+ udata/core/dataset/apiv2.py,sha256=YOCNqQh7_OODcrzqJqdAPc0CoB9vG0DVcFiJNl9yBwQ,20749
100
100
  udata/core/dataset/commands.py,sha256=__hPAk_6iHtgMnEG51ux0vbNWJHxUjXhi1ukH4hF5jY,3714
101
101
  udata/core/dataset/constants.py,sha256=fKn21GzRShZv6pzKy3TvEK1cevQ9H3dOFE-xTRuE0lA,2971
102
- udata/core/dataset/csv.py,sha256=aNJOytbFbH8OCYr6hyaSaqFSa94Xb3dvBd3QGZHJRsA,3633
102
+ udata/core/dataset/csv.py,sha256=OmfHUX5d325XJva2lqHNEBJz3vROfEqkiu1rBfS6Reg,3612
103
103
  udata/core/dataset/events.py,sha256=bSM0nFEX14r4JHc-bAM-7OOuD3JAxUIpw9GgXbOsUyw,4078
104
104
  udata/core/dataset/exceptions.py,sha256=uKiayLSpSzsnLvClObS6hOO0qXEqvURKN7_w8eimQNU,498
105
105
  udata/core/dataset/factories.py,sha256=fRDWDlybR_ud4pDs1-ntWuYHKtV9LMHeBOBp2SmTT6M,9006
106
106
  udata/core/dataset/forms.py,sha256=7KUxuFcEGT0MUe0cZCiZtsnZhvGgvEd68pe13NgeSMI,6292
107
- udata/core/dataset/models.py,sha256=2c6vjr5KPq6Pqg6MK5pRFrXzpTIXtRC2zRxDlxiFTL8,40834
107
+ udata/core/dataset/models.py,sha256=lu-EFDSWa8qz81LbI39F1XsTO5Tv2QfEbEp5ieq-WIE,40710
108
108
  udata/core/dataset/permissions.py,sha256=zXQ6kU-Ni3Pl5tDtat-ZPupug9InsNeCN7xRLc2Vcrc,1097
109
109
  udata/core/dataset/preview.py,sha256=IwCqiNTjjXbtA_SSKF52pwnzKKEz0GyYM95QNn2Dkog,2561
110
110
  udata/core/dataset/rdf.py,sha256=HkjzcWgq9AfPvUGMRI7-ufRrgnlfBmP8crbgRhg6Lz4,31789
@@ -125,7 +125,7 @@ udata/core/discussions/permissions.py,sha256=VY2_PEsazz1fBgCX9-K-_spRgxUoNY4HuND
125
125
  udata/core/discussions/signals.py,sha256=tJ83RJIsBAny08Q6IDwehE6lDDRf6ynIFCl0WqnayoU,543
126
126
  udata/core/discussions/tasks.py,sha256=j78n9Pv04ftyt5KJHVZQwaxjgxDqyc9jbV49286A0wE,2761
127
127
  udata/core/followers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
- udata/core/followers/api.py,sha256=ShJ6DPjpAAQLM51gjMWf7d4TZjZA2VqP8I2YBHPCfhA,2777
128
+ udata/core/followers/api.py,sha256=oCkEl_NUuizkssowlUyzCNK5IUq8GjNLVz1HN4HVqlg,2904
129
129
  udata/core/followers/metrics.py,sha256=nKgoiM2Gu-XHrgEf9duW1My66zFSKbmw25BGqo5wWtY,190
130
130
  udata/core/followers/models.py,sha256=PvExrmKbdr0oFjoMYfg1ZUuFlPYGCKKwrE0_ouPaILs,1122
131
131
  udata/core/followers/signals.py,sha256=q0su1eArVO1pnCoNFDieG-kW3iL-hLuXTmnU1-NXNF0,528
@@ -181,7 +181,7 @@ udata/core/reuse/constants.py,sha256=JgDBrjOKSt9q0auv9rjzbGsch83H-Oi8YXAKeI5hO4o
181
181
  udata/core/reuse/csv.py,sha256=hCvKYzbL6kiUwzHkd9jrexdeACBj5k7XycKaLZesQeo,892
182
182
  udata/core/reuse/factories.py,sha256=GrQqYTIvwQrwkvJrbTr38-2faFW_PC99gn3yOVpgFec,850
183
183
  udata/core/reuse/metrics.py,sha256=sVh7BlW3OKRvFDHFyD4pPUV91jOOhj8qeWbBkLPn5Gg,176
184
- udata/core/reuse/models.py,sha256=ibPCh7_O3_astx4u4v1m83fRAlbajL4rZuZVGWsYZ3Y,8666
184
+ udata/core/reuse/models.py,sha256=Mb8us6MXaIHhKRVtdAE-9bPdMUm91EUeb_dBOLbI3FM,8669
185
185
  udata/core/reuse/permissions.py,sha256=j-ancS7gvLl5vJu0TNYqpYD-2So-UzoDE4IHLxRoMGg,621
186
186
  udata/core/reuse/search.py,sha256=y1DwXYkBMBwuhn62CULkU1NNo89IYp0Ae7U01jcnjBY,3137
187
187
  udata/core/reuse/signals.py,sha256=nDrEUpYKN0AdYiEbrR0z3nzXzjaRcD8SAMutwIDsQPM,155
@@ -626,7 +626,7 @@ udata/tests/api/test_auth_api.py,sha256=OMRlY0OQt60j5N4A-N3HdWTuffOjRlFHkz5a3jJF
626
626
  udata/tests/api/test_base_api.py,sha256=2w_vz0eEuq3P3aN-ByvxGc3VZAo7XtgatFfcrzf2uEU,2244
627
627
  udata/tests/api/test_contact_points.py,sha256=X_RWD_xCfR8WchhHfKEt5mxMHY77OmTyguNKCsZftdE,5337
628
628
  udata/tests/api/test_dataservices_api.py,sha256=fNpeHl4SMvci3QrC414X6KGorv7NS1y8LsGxcSMjjZY,25729
629
- udata/tests/api/test_datasets_api.py,sha256=3EQdnP0DX-6mmPP-1hQrMTOPE1ZxLFIgB5Y4bKvH27k,97751
629
+ udata/tests/api/test_datasets_api.py,sha256=Igu8NrOfDEtYKjlG7CrL_VpiFN2Tp6W-Kj4r8mpK1os,98789
630
630
  udata/tests/api/test_fields.py,sha256=OW85Z5MES5HeWOpapeem8OvR1cIcrqW-xMWpdZO4LZ8,1033
631
631
  udata/tests/api/test_follow_api.py,sha256=XP6I96JUNT6xjGcQOF7pug_T_i67HzCiOGLaPdpfpEQ,4912
632
632
  udata/tests/api/test_me_api.py,sha256=YPd8zmR3zwJKtpSqz8nY1nOOMyXs66INeBwyhg5D0Us,13846
@@ -653,7 +653,7 @@ udata/tests/dataservice/test_csv_adapter.py,sha256=UyDPiqKIDwe0AdXLKLpSsBqe4ZJsf
653
653
  udata/tests/dataservice/test_dataservice_rdf.py,sha256=VLFgdclFoIhmctfMEgTxvuNlRxcI1yDkZWE-lbEYGdQ,2984
654
654
  udata/tests/dataservice/test_dataservice_tasks.py,sha256=9XUoYLb_p3dzmgLfswaXjMG2civP0i1kzzP4VdJWE0k,1614
655
655
  udata/tests/dataset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
656
- udata/tests/dataset/test_csv_adapter.py,sha256=CSAHEur5-183fRsD_cBgsHnLuohn0DOb9zkVT1q0PNo,3866
656
+ udata/tests/dataset/test_csv_adapter.py,sha256=7U83RiuSKNVgX-mV45Txp9a828mnWE4eKrU7K-36Dbs,3906
657
657
  udata/tests/dataset/test_dataset_actions.py,sha256=bgDjVYjOvu3sX_FCTCzf2snZYSprsqor2nAhIVuokSs,722
658
658
  udata/tests/dataset/test_dataset_commands.py,sha256=zMPJG2wYwKBee2zI65kmboxf59Zqa84DDjT8V5wj9uo,801
659
659
  udata/tests/dataset/test_dataset_events.py,sha256=hlrpoOiBbnX_COUI9Pzdqlp45GZZDqu5piwupbnPiTI,3601
@@ -726,9 +726,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=ViV14tUmjSydHS0TWG_mFikKQfyUaT
726
726
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=rzAD_MVoV54TmN3w1ECz3H2Ru5pM7hWMVH03SkY28Q8,47250
727
727
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=EHX1_D-Uglj38832G7BrA0QC5IuY3p8dKqi9T0DgPmE,29169
728
728
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=3PMnbVhKVJh6Q8ABi1ZTZ8Dcf-sMjngLJZqLbonJoec,54225
729
- udata-10.4.0.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
730
- udata-10.4.0.dist-info/METADATA,sha256=rQ_hAThkecUmXeKvQo2a2RMy-Nm54lCvHFKL9FFpJRg,146016
731
- udata-10.4.0.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
732
- udata-10.4.0.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
733
- udata-10.4.0.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
734
- udata-10.4.0.dist-info/RECORD,,
729
+ udata-10.4.1.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
730
+ udata-10.4.1.dist-info/METADATA,sha256=Mtwesjx1gVcNvjTC4eEekYJSrfKXqaw2WqbWsdTbwKA,146445
731
+ udata-10.4.1.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
732
+ udata-10.4.1.dist-info/entry_points.txt,sha256=ETvkR4r6G1duBsh_V_fGWENQy17GTFuobi95MYBAl1A,498
733
+ udata-10.4.1.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
734
+ udata-10.4.1.dist-info/RECORD,,
File without changes