udata 7.0.5.dev28083__py2.py3-none-any.whl → 7.0.5.dev28120__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/core/spatial/commands.py +20 -0
- udata/core/topic/api.py +4 -0
- udata/core/topic/apiv2.py +4 -0
- udata/core/topic/forms.py +5 -0
- udata/core/topic/models.py +3 -1
- udata/tests/api/test_topics_api.py +25 -0
- udata/tests/apiv2/test_topics.py +1 -0
- {udata-7.0.5.dev28083.dist-info → udata-7.0.5.dev28120.dist-info}/METADATA +3 -2
- {udata-7.0.5.dev28083.dist-info → udata-7.0.5.dev28120.dist-info}/RECORD +13 -13
- {udata-7.0.5.dev28083.dist-info → udata-7.0.5.dev28120.dist-info}/LICENSE +0 -0
- {udata-7.0.5.dev28083.dist-info → udata-7.0.5.dev28120.dist-info}/WHEEL +0 -0
- {udata-7.0.5.dev28083.dist-info → udata-7.0.5.dev28120.dist-info}/entry_points.txt +0 -0
- {udata-7.0.5.dev28083.dist-info → udata-7.0.5.dev28120.dist-info}/top_level.txt +0 -0
udata/core/spatial/commands.py
CHANGED
|
@@ -141,6 +141,10 @@ def load(geozones_file, levels_file, drop=False):
|
|
|
141
141
|
total = load_zones(GeoZone, json_geozones)
|
|
142
142
|
log.info('Loaded {total} zones'.format(total=total))
|
|
143
143
|
|
|
144
|
+
log.info('Clean removed geozones in datasets')
|
|
145
|
+
count = fixup_removed_geozone()
|
|
146
|
+
log.info(f'{count} geozones removed from datasets')
|
|
147
|
+
|
|
144
148
|
|
|
145
149
|
@grp.command()
|
|
146
150
|
def migrate():
|
|
@@ -188,3 +192,19 @@ def migrate():
|
|
|
188
192
|
'''.format(level_summary, **counter)), level_summary])
|
|
189
193
|
log.info(summary)
|
|
190
194
|
log.info('Done')
|
|
195
|
+
|
|
196
|
+
def fixup_removed_geozone():
|
|
197
|
+
count = 0
|
|
198
|
+
all_datasets = Dataset.objects(spatial__zones__0__exists=True).timeout(False)
|
|
199
|
+
for dataset in all_datasets:
|
|
200
|
+
zones = dataset.spatial.zones
|
|
201
|
+
new_zones = [z for z in zones if getattr(z, 'name', None) is not None]
|
|
202
|
+
|
|
203
|
+
if len(new_zones) < len(zones):
|
|
204
|
+
log.debug(f"Removing deleted zones from dataset '{dataset.title}'")
|
|
205
|
+
count += len(zones) - len(new_zones)
|
|
206
|
+
dataset.spatial.zones = new_zones
|
|
207
|
+
dataset.save()
|
|
208
|
+
|
|
209
|
+
return count
|
|
210
|
+
|
udata/core/topic/api.py
CHANGED
|
@@ -3,6 +3,7 @@ from udata.core.dataset.api_fields import dataset_fields
|
|
|
3
3
|
from udata.core.discussions.models import Discussion
|
|
4
4
|
from udata.core.organization.api_fields import org_ref_fields
|
|
5
5
|
from udata.core.reuse.api_fields import reuse_fields
|
|
6
|
+
from udata.core.spatial.api_fields import spatial_coverage_fields
|
|
6
7
|
from udata.core.topic.permissions import TopicEditPermission
|
|
7
8
|
from udata.core.topic.parsers import TopicApiParser
|
|
8
9
|
from udata.core.user.api_fields import user_ref_fields
|
|
@@ -37,6 +38,9 @@ topic_fields = api.model('Topic', {
|
|
|
37
38
|
'private': fields.Boolean(description='Is the topic private'),
|
|
38
39
|
'created_at': fields.ISODateTime(
|
|
39
40
|
description='The topic creation date', readonly=True),
|
|
41
|
+
'spatial': fields.Nested(
|
|
42
|
+
spatial_coverage_fields, allow_null=True,
|
|
43
|
+
description='The spatial coverage'),
|
|
40
44
|
'last_modified': fields.ISODateTime(
|
|
41
45
|
description='The topic last modification date', readonly=True),
|
|
42
46
|
'organization': fields.Nested(
|
udata/core/topic/apiv2.py
CHANGED
|
@@ -13,6 +13,7 @@ from udata.core.organization.api_fields import org_ref_fields
|
|
|
13
13
|
from udata.core.reuse.api import ReuseApiParser
|
|
14
14
|
from udata.core.reuse.apiv2 import reuse_page_fields
|
|
15
15
|
from udata.core.reuse.models import Reuse
|
|
16
|
+
from udata.core.spatial.api_fields import spatial_coverage_fields
|
|
16
17
|
from udata.core.topic.models import Topic
|
|
17
18
|
from udata.core.topic.parsers import TopicApiParser
|
|
18
19
|
from udata.core.topic.permissions import TopicEditPermission
|
|
@@ -63,6 +64,9 @@ topic_fields = apiv2.model('Topic', {
|
|
|
63
64
|
'private': fields.Boolean(description='Is the topic private'),
|
|
64
65
|
'created_at': fields.ISODateTime(
|
|
65
66
|
description='The topic creation date', readonly=True),
|
|
67
|
+
'spatial': fields.Nested(
|
|
68
|
+
spatial_coverage_fields, allow_null=True,
|
|
69
|
+
description='The spatial coverage'),
|
|
66
70
|
'last_modified': fields.ISODateTime(
|
|
67
71
|
description='The topic last modification date', readonly=True),
|
|
68
72
|
'organization': fields.Nested(
|
udata/core/topic/forms.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from udata.forms import ModelForm, fields, validators
|
|
2
|
+
from udata.core.spatial.forms import SpatialCoverageField
|
|
2
3
|
from udata.i18n import lazy_gettext as _
|
|
3
4
|
|
|
4
5
|
from .models import Topic
|
|
@@ -20,6 +21,10 @@ class TopicForm(ModelForm):
|
|
|
20
21
|
datasets = fields.DatasetListField(_('Associated datasets'))
|
|
21
22
|
reuses = fields.ReuseListField(_('Associated reuses'))
|
|
22
23
|
|
|
24
|
+
spatial = SpatialCoverageField(
|
|
25
|
+
_('Spatial coverage'),
|
|
26
|
+
description=_('The geographical area covered by the data.'))
|
|
27
|
+
|
|
23
28
|
tags = fields.TagField(_('Tags'), [validators.DataRequired()])
|
|
24
29
|
private = fields.BooleanField(_('Private'))
|
|
25
30
|
featured = fields.BooleanField(_('Featured'))
|
udata/core/topic/models.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from flask import url_for
|
|
2
2
|
from mongoengine.signals import pre_save
|
|
3
|
-
from udata.models import db
|
|
3
|
+
from udata.models import db, SpatialCoverage
|
|
4
4
|
from udata.search import reindex
|
|
5
5
|
from udata.tasks import as_task_param
|
|
6
6
|
|
|
@@ -26,6 +26,8 @@ class Topic(db.Document, db.Owned, db.Datetimed):
|
|
|
26
26
|
private = db.BooleanField()
|
|
27
27
|
extras = db.ExtrasField()
|
|
28
28
|
|
|
29
|
+
spatial = db.EmbeddedDocumentField(SpatialCoverage)
|
|
30
|
+
|
|
29
31
|
meta = {
|
|
30
32
|
'indexes': [
|
|
31
33
|
'$name',
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
from flask import url_for
|
|
2
2
|
|
|
3
3
|
from udata.core.organization.factories import OrganizationFactory
|
|
4
|
+
from udata.core.spatial.models import spatial_granularities
|
|
4
5
|
from udata.core.topic.models import Topic
|
|
5
6
|
from udata.core.topic.factories import TopicFactory
|
|
6
7
|
from udata.core.user.factories import UserFactory
|
|
7
8
|
from udata.models import Member, Discussion
|
|
9
|
+
from udata.tests.api.test_datasets_api import SAMPLE_GEOM
|
|
10
|
+
from udata.tests.features.territories import create_geozones_fixtures
|
|
8
11
|
|
|
9
12
|
from . import APITestCase
|
|
10
13
|
|
|
@@ -53,6 +56,8 @@ class TopicsAPITest(APITestCase):
|
|
|
53
56
|
self.assert200(response)
|
|
54
57
|
|
|
55
58
|
data = response.json
|
|
59
|
+
self.assertIn('spatial', data)
|
|
60
|
+
|
|
56
61
|
for dataset, expected in zip(data['datasets'], [d.fetch() for d in topic.datasets]):
|
|
57
62
|
self.assertEqual(dataset['id'], str(expected.id))
|
|
58
63
|
self.assertEqual(dataset['title'], str(expected.title))
|
|
@@ -100,6 +105,26 @@ class TopicsAPITest(APITestCase):
|
|
|
100
105
|
assert topic.owner is None
|
|
101
106
|
assert topic.organization == org
|
|
102
107
|
|
|
108
|
+
def test_topic_api_create_spatial(self):
|
|
109
|
+
paca, _, _ = create_geozones_fixtures()
|
|
110
|
+
granularity = spatial_granularities[0][0]
|
|
111
|
+
data = TopicFactory.as_dict()
|
|
112
|
+
data['datasets'] = [str(d.id) for d in data['datasets']]
|
|
113
|
+
data['reuses'] = [str(r.id) for r in data['reuses']]
|
|
114
|
+
data['spatial'] = {
|
|
115
|
+
'zones': [paca.id],
|
|
116
|
+
'geom': SAMPLE_GEOM,
|
|
117
|
+
'granularity': granularity,
|
|
118
|
+
}
|
|
119
|
+
self.login()
|
|
120
|
+
response = self.post(url_for('api.topics'), data)
|
|
121
|
+
self.assert201(response)
|
|
122
|
+
self.assertEqual(Topic.objects.count(), 1)
|
|
123
|
+
topic = Topic.objects.first()
|
|
124
|
+
self.assertEqual([str(z) for z in topic.spatial.zones], [paca.id])
|
|
125
|
+
self.assertEqual(topic.spatial.geom, SAMPLE_GEOM)
|
|
126
|
+
self.assertEqual(topic.spatial.granularity, granularity)
|
|
127
|
+
|
|
103
128
|
def test_topic_api_update(self):
|
|
104
129
|
'''It should update a topic from the API'''
|
|
105
130
|
owner = self.login()
|
udata/tests/apiv2/test_topics.py
CHANGED
|
@@ -40,6 +40,7 @@ class TopicsAPITest(APITestCase):
|
|
|
40
40
|
topic = TopicFactory()
|
|
41
41
|
topic_response = self.get(url_for('apiv2.topic', topic=topic))
|
|
42
42
|
assert topic_response.status_code == 200
|
|
43
|
+
assert 'spatial' in topic_response.json
|
|
43
44
|
|
|
44
45
|
assert topic_response.json['created_at'] is not None
|
|
45
46
|
assert topic_response.json['last_modified'] is not None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 7.0.5.
|
|
3
|
+
Version: 7.0.5.dev28120
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -145,7 +145,8 @@ It is collectively taken care of by members of the
|
|
|
145
145
|
- Allow harvesting of big catalog (bigger than 16MB) [#2980](https://github.com/opendatateam/udata/pull/2980) [2985](https://github.com/opendatateam/udata/pull/2985)
|
|
146
146
|
- Add downloads' count to organizations CSV [#2973](https://github.com/opendatateam/udata/pull/2973)
|
|
147
147
|
- Add 3 new badges to the organization model : `company`, `association` and `local authority` [#2984](https://github.com/opendatateam/udata/pull/2984)
|
|
148
|
-
- Prevent geozones listed ad `deleted` to be loaded [#2983](https://github.com/opendatateam/udata/pull/2983)
|
|
148
|
+
- Prevent geozones listed ad `deleted` to be loaded [#2983](https://github.com/opendatateam/udata/pull/2983) [#2993](https://github.com/opendatateam/udata/pull/2993)
|
|
149
|
+
- Topic: add spatial field [#2988](https://github.com/opendatateam/udata/pull/2988)
|
|
149
150
|
- Topic: add last_modified field [#2987](https://github.com/opendatateam/udata/pull/2987)
|
|
150
151
|
- Add stacktraces to CSV errors [#2990](https://github.com/opendatateam/udata/pull/2990)
|
|
151
152
|
|
|
@@ -178,7 +178,7 @@ udata/core/spam/tests/test_spam.py,sha256=IuSRVoVCLBjJuoCXnPZx8XjtRyt5q2LrSBtIp8
|
|
|
178
178
|
udata/core/spatial/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
179
179
|
udata/core/spatial/api.py,sha256=tlApg3JpqbO6CwEwp1LzZ1hyPQreVEgF3H5yrcAPE74,5848
|
|
180
180
|
udata/core/spatial/api_fields.py,sha256=ymGK3FyE2KNlASOU5GiPgZGeBjjOqnOyCOcRCbuw3D8,2629
|
|
181
|
-
udata/core/spatial/commands.py,sha256=
|
|
181
|
+
udata/core/spatial/commands.py,sha256=qdJ4mUg3NUTrGx6L5MKPh1usvxmeCn8xMCZNGKyjWYE,6914
|
|
182
182
|
udata/core/spatial/factories.py,sha256=GxUU8nRtSoGPw2m3Q-al0PYps2oSnlqC-bM7Eeu14rk,3288
|
|
183
183
|
udata/core/spatial/forms.py,sha256=tXlYKge5Rc8L8pOjfUo1-9howgVJZDAh7q8xTIlbBww,3218
|
|
184
184
|
udata/core/spatial/geoids.py,sha256=UqCto4dtQYPXOxyG7sx_0npzM6yvId40ngw3eAlmioQ,1159
|
|
@@ -201,11 +201,11 @@ udata/core/tags/models.py,sha256=qOvZPBT7d_sSy2iaEDBQs5LK3ksTo6Oim04THO8ftMM,530
|
|
|
201
201
|
udata/core/tags/tasks.py,sha256=BXBJF45t2DmbWsNgLYkuUC9vBGqJ_Dftye5SmHEOttk,1055
|
|
202
202
|
udata/core/tags/views.py,sha256=BoBktrbx0tqkIu3yYLj_XJjB7ZHu_tq5vfEBrh0MUwI,384
|
|
203
203
|
udata/core/topic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
204
|
-
udata/core/topic/api.py,sha256=
|
|
205
|
-
udata/core/topic/apiv2.py,sha256=
|
|
204
|
+
udata/core/topic/api.py,sha256=G3hN4e9rK5mIYvDLvPpAOo_DN2SySAGykVVvXGx4uMY,5105
|
|
205
|
+
udata/core/topic/apiv2.py,sha256=cf-WUSZ7P6Tss3S8utS-uhreLgGI5XR3nn_1UWiZ_Xs,9846
|
|
206
206
|
udata/core/topic/factories.py,sha256=BEk6YZdaHK-XzCNyD5v_HIKahMe7Lp8aKOlCZLuivtk,711
|
|
207
|
-
udata/core/topic/forms.py,sha256=
|
|
208
|
-
udata/core/topic/models.py,sha256=
|
|
207
|
+
udata/core/topic/forms.py,sha256=XqGI4nANdsm2UkIiGAuVqEdZkN5N9sqJ4VaM_PhTaVQ,987
|
|
208
|
+
udata/core/topic/models.py,sha256=PZsYfiuEU86iL1x-qvDevn4Io8lKGahAbqky03j1N2k,2071
|
|
209
209
|
udata/core/topic/parsers.py,sha256=oe_4ehnlgPKre2GG1LA6hcQa6H5V5q1adUsQIzVqb_Q,876
|
|
210
210
|
udata/core/topic/permissions.py,sha256=RtFPPlxuU_Bv7ip6LDO4AoPrKFnIOEs9cCMXaSSmEdk,118
|
|
211
211
|
udata/core/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -573,14 +573,14 @@ udata/tests/api/test_organizations_api.py,sha256=HxeTqP14wlWGaQt4fpQljuRy98HWnmL
|
|
|
573
573
|
udata/tests/api/test_reuses_api.py,sha256=gQ-o4JXK2S6z2yW13-i8e81pCdr9j2yyM1KinPbkc5g,16971
|
|
574
574
|
udata/tests/api/test_swagger.py,sha256=tLg452rCD5Q0AgFXOVZKMM6jGiWwC5diX5PxbdYni0o,760
|
|
575
575
|
udata/tests/api/test_tags_api.py,sha256=xSIx_x5gqKz6BJCXKEsTqA_CR4BF1nG5NxEyfp9dy0o,2579
|
|
576
|
-
udata/tests/api/test_topics_api.py,sha256=
|
|
576
|
+
udata/tests/api/test_topics_api.py,sha256=BYkfBJpz58DbCZ_fgPvpH0unKPJ1PY8B5dm9Km4YWkQ,7586
|
|
577
577
|
udata/tests/api/test_transfer_api.py,sha256=aGGJp79YYHQQyMAKhp7urk4eD587v3kbIy-8rJ_kk1s,2901
|
|
578
578
|
udata/tests/api/test_user_api.py,sha256=NVXsn-sRrMQYbbUyJ2_I2_C3UPfzgCZv-us6RvM5VE8,13597
|
|
579
579
|
udata/tests/apiv2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
580
580
|
udata/tests/apiv2/test_datasets.py,sha256=j2cuaGtTnpF5TAvuzMEmx0uEXvuANlIKS5quupJocx4,17953
|
|
581
581
|
udata/tests/apiv2/test_organizations.py,sha256=CpNG8xl13rZXxTN2-JRx9ZkyI7IuQUaOsNuumUxuB3I,6704
|
|
582
582
|
udata/tests/apiv2/test_swagger.py,sha256=D8jpRqDUmqVkNVYkYaXfvMPUc7OBVs_dMsC13KZciWE,785
|
|
583
|
-
udata/tests/apiv2/test_topics.py,sha256=
|
|
583
|
+
udata/tests/apiv2/test_topics.py,sha256=d30tJU167B5r8WWBHvI9rKdjnGrVpf7-HyvKlWyaxtc,8260
|
|
584
584
|
udata/tests/cli/test_cli_base.py,sha256=piqoq4Ib5bdZQpuUAJh583qfjCSglWZQclKzhO3Yr_0,321
|
|
585
585
|
udata/tests/cli/test_db_cli.py,sha256=-hw9SU3RvNT7fvqVtQHxEpKstnjMU4L_DY9tiBH-ybs,1726
|
|
586
586
|
udata/tests/data/image.jpg,sha256=hdmpaCjOhmAAfNGuTqWKEjv7IC4GXJx-nP_rT274hc8,337049
|
|
@@ -658,9 +658,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=dXTr2zzGPgclSMzAJo4qhOEVHYWYP7
|
|
|
658
658
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=G-MNwE4Gih-4w-xNAjp7PAvQOeW1uyM-27Z6O08_SCc,42104
|
|
659
659
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=5bvKeJp9nqk76tZsgbGC2qnbpJws5lODdMcezr6LKbQ,28553
|
|
660
660
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=d_uBu93oIsmeewv8QzrB2Z8tmkUXn8juwT5OiySALog,48684
|
|
661
|
-
udata-7.0.5.
|
|
662
|
-
udata-7.0.5.
|
|
663
|
-
udata-7.0.5.
|
|
664
|
-
udata-7.0.5.
|
|
665
|
-
udata-7.0.5.
|
|
666
|
-
udata-7.0.5.
|
|
661
|
+
udata-7.0.5.dev28120.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
662
|
+
udata-7.0.5.dev28120.dist-info/METADATA,sha256=Qum0kYJJX9EDfQ9n2ACO4H-5bwmi-TEIV5FJGQD3wuk,119267
|
|
663
|
+
udata-7.0.5.dev28120.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
|
|
664
|
+
udata-7.0.5.dev28120.dist-info/entry_points.txt,sha256=ZqIUHhOth0MMQvMIeuhODbUCDwjR-Hvo7PaKrMwTKuQ,384
|
|
665
|
+
udata-7.0.5.dev28120.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
666
|
+
udata-7.0.5.dev28120.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|