udata 14.5.1.dev9__py3-none-any.whl → 14.5.1.dev11__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/post/models.py CHANGED
@@ -4,6 +4,7 @@ from udata.api_fields import field, generate_fields
4
4
  from udata.core.dataset.api_fields import dataset_fields
5
5
  from udata.core.linkable import Linkable
6
6
  from udata.core.storages import default_image_basename, images
7
+ from udata.core.user.api_fields import user_ref_fields
7
8
  from udata.i18n import lazy_gettext as _
8
9
  from udata.mongo import db
9
10
  from udata.uris import cdata_url
@@ -82,6 +83,7 @@ class Post(db.Datetimed, Linkable, db.Document):
82
83
 
83
84
  owner = field(
84
85
  db.ReferenceField("User"),
86
+ nested_fields=user_ref_fields,
85
87
  readonly=True,
86
88
  allow_null=True,
87
89
  description="The owner user",
@@ -56,9 +56,13 @@ class PostsAPITest(APITestCase):
56
56
 
57
57
  def test_post_api_get(self):
58
58
  """It should fetch a post from the API"""
59
- post = PostFactory()
59
+ admin = AdminFactory()
60
+ post = PostFactory(owner=admin)
60
61
  response = self.get(url_for("api.post", post=post))
61
62
  assert200(response)
63
+ owner = response.json["owner"]
64
+ assert isinstance(owner, dict)
65
+ assert owner["id"] == str(admin.id)
62
66
 
63
67
  def test_post_api_create(self):
64
68
  """It should create a post from the API"""
@@ -5,6 +5,7 @@ Remove Harvest db integrity problems
5
5
 
6
6
  import logging
7
7
 
8
+ import click
8
9
  import mongoengine
9
10
 
10
11
  from udata.core.jobs.models import PeriodicTask
@@ -16,29 +17,35 @@ log = logging.getLogger(__name__)
16
17
  def migrate(db):
17
18
  log.info("Processing HarvestJob source references.")
18
19
 
19
- harvest_jobs = HarvestJob.objects().no_cache().all()
20
+ harvest_jobs = HarvestJob.objects().no_cache()
21
+ total = harvest_jobs.count()
20
22
  count = 0
21
- for harvest_job in harvest_jobs:
22
- try:
23
- harvest_job.source.id
24
- except mongoengine.errors.DoesNotExist:
25
- count += 1
26
- harvest_job.delete()
23
+ with click.progressbar(harvest_jobs, length=total, label="Checking sources refs") as jobs:
24
+ for harvest_job in jobs:
25
+ try:
26
+ if harvest_job.source is None:
27
+ raise mongoengine.errors.DoesNotExist()
28
+ harvest_job.source.id
29
+ except mongoengine.errors.DoesNotExist:
30
+ count += 1
31
+ harvest_job.delete()
27
32
 
28
33
  log.info(f"Completed, removed {count} HarvestJob objects")
29
34
 
30
35
  log.info("Processing HarvestJob items references.")
31
36
 
32
- harvest_jobs = HarvestJob.objects.filter(items__0__exists=True).no_cache().all()
37
+ harvest_jobs = HarvestJob.objects.filter(items__0__exists=True).no_cache()
38
+ total = harvest_jobs.count()
33
39
  count = 0
34
- for harvest_job in harvest_jobs:
35
- for item in harvest_job.items:
36
- try:
37
- item.dataset and item.dataset.id
38
- except mongoengine.errors.DoesNotExist:
39
- count += 1
40
- item.dataset = None
41
- harvest_job.save()
40
+ with click.progressbar(harvest_jobs, length=total, label="Checking items refs") as jobs:
41
+ for harvest_job in jobs:
42
+ for item in harvest_job.items:
43
+ try:
44
+ item.dataset and item.dataset.id
45
+ except mongoengine.errors.DoesNotExist:
46
+ count += 1
47
+ item.dataset = None
48
+ harvest_job.save()
42
49
 
43
50
  log.info(f"Completed, modified {count} HarvestJob objects")
44
51
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: udata
3
- Version: 14.5.1.dev9
3
+ Version: 14.5.1.dev11
4
4
  Summary: Open data portal
5
5
  Author-email: Opendata Team <opendatateam@data.gouv.fr>
6
6
  Maintainer-email: Opendata Team <opendatateam@data.gouv.fr>
@@ -178,10 +178,10 @@ udata/core/post/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
178
178
  udata/core/post/api.py,sha256=H8IKX5x9MqcG36Y60DRxOhC00HKyhwLX5lvvSB2AO5c,4863
179
179
  udata/core/post/constants.py,sha256=W-xjOTv0lorD-RCV0YGtK0cT_RwgYmfrC8Ff6ywH7bM,215
180
180
  udata/core/post/factories.py,sha256=lcFe3zIadG7bc1jsydkOT7GfQX53V0x09Flpclyl6gI,619
181
- udata/core/post/models.py,sha256=BuctB_YvthUZh7gibtnBrPeTd2rAxug3Blvf5i6JIok,3780
181
+ udata/core/post/models.py,sha256=p-p-MopRiNic02fTdLR3ECOFUR_nwS2xliTM9dujo0U,3874
182
182
  udata/core/post/permissions.py,sha256=uofU0TehhOGYyUoRXf3wuy816_D3xwMmaJbDvV336sw,83
183
183
  udata/core/post/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
184
- udata/core/post/tests/test_api.py,sha256=zaKfeBdG_cMdUXJ7-qGQIRyVO1t09h-kiJR2nw83bQk,6183
184
+ udata/core/post/tests/test_api.py,sha256=eJWInJtMw4AHS5OpXTaW8oGLi_DdMrkWaSB3hYNQi8s,6347
185
185
  udata/core/reports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
186
186
  udata/core/reports/api.py,sha256=qrGi1DdRN4mO4nWcyG9rKMiBlw4C8UnzecJFqNAgF_8,2185
187
187
  udata/core/reports/constants.py,sha256=LRZSX3unyqZeB4yQjK3ws_hGbJcXYk4bu1Rhnhi5DEs,1235
@@ -371,7 +371,7 @@ udata/migrations/2021-05-27-fix-default-schema-name.py,sha256=n377iZDBGMivMvm_Ar
371
371
  udata/migrations/2021-07-05-remove-unused-badges.py,sha256=KJdDgCkCCevsmZ1n-xHnUwYgMK4MmgM67UEE_8oDdAA,921
372
372
  udata/migrations/2021-07-07-update-schema-for-community-resources.py,sha256=gj-CAQsGQ_lc7bmgZSo6sMqKLjgIYaLQShfC42Lql8w,866
373
373
  udata/migrations/2021-08-17-follow-integrity.py,sha256=wUpsXwTCaXFdhFW3zltvswm_Z0d0RafYsEandgJJ1QQ,532
374
- udata/migrations/2021-08-17-harvest-integrity.py,sha256=L0mEqlY6ekspIpPFq93grI6Gn1tT_Ii1WHaq_ORAMbU,1611
374
+ udata/migrations/2021-08-17-harvest-integrity.py,sha256=pm9ofGmXay1DMmlB2K-VsAOPqwLrKUFvOsWC8x9Zi7w,2013
375
375
  udata/migrations/2021-08-17-oauth2client-integrity.py,sha256=SP8xqZCIBrNfFDlDMU4zcq5JaXdJ__qm19QtsGNvQic,598
376
376
  udata/migrations/2021-08-17-transfer-integrity.py,sha256=zXVwwS7YnsiXB7sY0fPSOXXTzJb0aRyJWVK4cT-SAcM,607
377
377
  udata/migrations/2021-08-17-users-integrity.py,sha256=IwRsIy0iQYzSm0-ESbfu7jjemRrm0o5RVRhJstllIKY,2094
@@ -580,9 +580,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=n7ZHvruSL9hIPoSl4aCkGeC52LZYeg
580
580
  udata/translations/pt/LC_MESSAGES/udata.po,sha256=24CsHDZ84nqTMr-cOvOZ-LNYsokLQNyQchI41o3Cq9M,49765
581
581
  udata/translations/sr/LC_MESSAGES/udata.mo,sha256=pw3gsvr8lPQJZvX9Jo8ymu59I3L6-rrpX2Fqy0Nu5r4,20441
582
582
  udata/translations/sr/LC_MESSAGES/udata.po,sha256=1h8akWRpcQ1uD5zezqjp-Q-gAld5_93MkJL4BRlqKjQ,54738
583
- udata-14.5.1.dev9.dist-info/licenses/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
584
- udata-14.5.1.dev9.dist-info/METADATA,sha256=HzZLmJ05MmH_cM_Dfph767hBvXEDJ7l-PC0lZ1mZ4bA,4358
585
- udata-14.5.1.dev9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
586
- udata-14.5.1.dev9.dist-info/entry_points.txt,sha256=XwrEzP-n_6CKnwTsrNHzyCTWbMwg2FkvxVVB686f_C0,476
587
- udata-14.5.1.dev9.dist-info/top_level.txt,sha256=EF6CE6YSHd_og-8LCEA4q25ALUpWVe8D0okOLdMAE3A,6
588
- udata-14.5.1.dev9.dist-info/RECORD,,
583
+ udata-14.5.1.dev11.dist-info/licenses/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
584
+ udata-14.5.1.dev11.dist-info/METADATA,sha256=trjyuqYYSgV-Z_WlafWqiw-iwiQu4DG3Or0AOGHXajo,4359
585
+ udata-14.5.1.dev11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
586
+ udata-14.5.1.dev11.dist-info/entry_points.txt,sha256=XwrEzP-n_6CKnwTsrNHzyCTWbMwg2FkvxVVB686f_C0,476
587
+ udata-14.5.1.dev11.dist-info/top_level.txt,sha256=EF6CE6YSHd_og-8LCEA4q25ALUpWVe8D0okOLdMAE3A,6
588
+ udata-14.5.1.dev11.dist-info/RECORD,,