udata 9.1.4__py2.py3-none-any.whl → 9.1.4.dev30973__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.
- tasks/__init__.py +2 -2
- udata/__init__.py +1 -1
- udata/api/__init__.py +3 -2
- udata/api/commands.py +1 -0
- udata/api/fields.py +1 -22
- udata/api_fields.py +37 -140
- udata/app.py +1 -1
- udata/auth/__init__.py +12 -8
- udata/commands/db.py +3 -3
- udata/commands/dcat.py +1 -1
- udata/commands/fixtures.py +40 -60
- udata/commands/purge.py +1 -2
- udata/commands/tests/test_fixtures.py +11 -44
- udata/core/activity/api.py +1 -14
- udata/core/activity/tasks.py +1 -1
- udata/core/badges/models.py +2 -6
- udata/core/contact_point/api.py +3 -1
- udata/core/dataservices/api.py +1 -37
- udata/core/dataservices/models.py +0 -38
- udata/core/dataservices/tasks.py +1 -1
- udata/core/dataset/events.py +1 -4
- udata/core/dataset/forms.py +2 -0
- udata/core/dataset/models.py +10 -12
- udata/core/dataset/rdf.py +1 -1
- udata/core/discussions/api.py +1 -1
- udata/core/discussions/models.py +2 -2
- udata/core/discussions/tasks.py +1 -1
- udata/core/metrics/models.py +1 -4
- udata/core/organization/api.py +7 -11
- udata/core/organization/api_fields.py +4 -10
- udata/core/organization/apiv2.py +1 -1
- udata/core/organization/csv.py +0 -1
- udata/core/organization/rdf.py +1 -4
- udata/core/owned.py +2 -4
- udata/core/post/api.py +2 -2
- udata/core/reuse/api.py +25 -32
- udata/core/reuse/api_fields.py +101 -2
- udata/core/reuse/apiv2.py +4 -4
- udata/core/reuse/forms.py +45 -0
- udata/core/reuse/models.py +16 -98
- udata/core/site/api.py +29 -3
- udata/core/spatial/commands.py +3 -3
- udata/core/spatial/factories.py +1 -1
- udata/core/spatial/forms.py +1 -1
- udata/core/spatial/models.py +2 -2
- udata/core/spatial/tests/test_models.py +1 -1
- udata/core/spatial/translations.py +1 -3
- udata/core/topic/api.py +2 -2
- udata/core/topic/apiv2.py +2 -1
- udata/core/user/api.py +8 -28
- udata/core/user/metrics.py +1 -1
- udata/cors.py +4 -4
- udata/features/transfer/api.py +2 -1
- udata/harvest/actions.py +1 -1
- udata/harvest/backends/__init__.py +1 -1
- udata/harvest/tasks.py +1 -0
- udata/harvest/tests/factories.py +2 -0
- udata/harvest/tests/test_base_backend.py +1 -0
- udata/harvest/tests/test_dcat_backend.py +17 -16
- udata/migrations/2020-07-24-remove-s-from-scope-oauth.py +1 -1
- udata/migrations/2021-07-05-remove-unused-badges.py +1 -0
- udata/migrations/2023-02-08-rename-internal-dates.py +2 -0
- udata/migrations/2024-06-11-fix-reuse-datasets-references.py +1 -0
- udata/mongo/datetime_fields.py +4 -11
- udata/mongo/document.py +0 -2
- udata/mongo/taglist_field.py +0 -26
- udata/search/commands.py +1 -1
- udata/search/query.py +1 -1
- udata/settings.py +0 -1
- udata/static/admin.js +36 -36
- udata/static/admin.js.map +1 -1
- udata/static/chunks/{12.576e63b7a990f8eab784.js → 12.5b900cac4417e10ef3a0.js} +2 -2
- udata/static/chunks/12.5b900cac4417e10ef3a0.js.map +1 -0
- udata/static/chunks/{28.1ef31a46255dc2bf56d1.js → 28.1759a7f57d526e6db574.js} +2 -2
- udata/static/chunks/28.1759a7f57d526e6db574.js.map +1 -0
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/api/test_base_api.py +1 -1
- udata/tests/api/test_contact_points.py +4 -4
- udata/tests/api/test_dataservices_api.py +0 -59
- udata/tests/api/test_datasets_api.py +10 -10
- udata/tests/api/test_organizations_api.py +39 -39
- udata/tests/api/test_reuses_api.py +0 -49
- udata/tests/api/test_tags_api.py +4 -4
- udata/tests/api/test_transfer_api.py +1 -1
- udata/tests/api/test_user_api.py +0 -11
- udata/tests/apiv2/test_datasets.py +4 -4
- udata/tests/dataset/test_dataset_events.py +0 -28
- udata/tests/dataset/test_dataset_model.py +3 -3
- udata/tests/frontend/__init__.py +2 -0
- udata/tests/frontend/test_auth.py +1 -0
- udata/tests/organization/test_csv_adapter.py +2 -0
- udata/tests/organization/test_notifications.py +3 -3
- udata/tests/organization/test_organization_rdf.py +6 -31
- udata/tests/reuse/test_reuse_model.py +1 -0
- udata/tests/site/test_site_rdf.py +3 -1
- udata/tests/test_cors.py +3 -0
- udata/tests/test_owned.py +4 -4
- udata/tests/test_routing.py +1 -1
- udata/tests/test_tags.py +1 -1
- udata/tests/test_transfer.py +2 -1
- udata/tests/workers/test_jobs_commands.py +1 -1
- udata/utils.py +0 -12
- {udata-9.1.4.dist-info → udata-9.1.4.dev30973.dist-info}/METADATA +4 -16
- {udata-9.1.4.dist-info → udata-9.1.4.dev30973.dist-info}/RECORD +109 -109
- udata/static/chunks/12.576e63b7a990f8eab784.js.map +0 -1
- udata/static/chunks/28.1ef31a46255dc2bf56d1.js.map +0 -1
- udata/tests/api/test_activities_api.py +0 -69
- {udata-9.1.4.dist-info → udata-9.1.4.dev30973.dist-info}/LICENSE +0 -0
- {udata-9.1.4.dist-info → udata-9.1.4.dev30973.dist-info}/WHEEL +0 -0
- {udata-9.1.4.dist-info → udata-9.1.4.dev30973.dist-info}/entry_points.txt +0 -0
- {udata-9.1.4.dist-info → udata-9.1.4.dev30973.dist-info}/top_level.txt +0 -0
udata/core/user/api.py
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
1
|
from flask_security import current_user, logout_user
|
|
4
2
|
from slugify import slugify
|
|
5
3
|
|
|
6
4
|
from udata.api import API, api
|
|
7
5
|
from udata.api.parsers import ModelApiParser
|
|
8
6
|
from udata.auth import admin_permission
|
|
7
|
+
from udata.core import storages
|
|
9
8
|
from udata.core.dataset.api_fields import community_resource_fields, dataset_fields
|
|
10
9
|
from udata.core.discussions.actions import discussions_for
|
|
11
10
|
from udata.core.discussions.api import discussion_fields
|
|
12
11
|
from udata.core.followers.api import FollowAPI
|
|
12
|
+
from udata.core.reuse.api_fields import reuse_fields
|
|
13
13
|
from udata.core.storages.api import (
|
|
14
14
|
image_parser,
|
|
15
15
|
parse_uploaded_image,
|
|
@@ -103,7 +103,7 @@ class AvatarAPI(API):
|
|
|
103
103
|
class MyReusesAPI(API):
|
|
104
104
|
@api.secure
|
|
105
105
|
@api.doc("my_reuses")
|
|
106
|
-
@api.marshal_list_with(
|
|
106
|
+
@api.marshal_list_with(reuse_fields)
|
|
107
107
|
def get(self):
|
|
108
108
|
"""List all my reuses (including private ones)"""
|
|
109
109
|
return list(Reuse.objects.owned_by(current_user.id))
|
|
@@ -166,7 +166,7 @@ class MyOrgReusesAPI(API):
|
|
|
166
166
|
@api.secure
|
|
167
167
|
@api.doc("my_org_reuses")
|
|
168
168
|
@api.expect(filter_parser)
|
|
169
|
-
@api.marshal_list_with(
|
|
169
|
+
@api.marshal_list_with(reuse_fields)
|
|
170
170
|
def get(self):
|
|
171
171
|
"""List all reuses related to me and my organizations."""
|
|
172
172
|
q = filter_parser.parse_args().get("q")
|
|
@@ -321,10 +321,9 @@ class UserAPI(API):
|
|
|
321
321
|
return "", 204
|
|
322
322
|
|
|
323
323
|
|
|
324
|
-
|
|
325
|
-
from udata.core.contact_point.
|
|
326
|
-
from udata.
|
|
327
|
-
from udata.models import ContactPoint # noqa
|
|
324
|
+
from udata.core.contact_point.api import ContactPointApiParser
|
|
325
|
+
from udata.core.contact_point.api_fields import contact_point_page_fields
|
|
326
|
+
from udata.models import ContactPoint
|
|
328
327
|
|
|
329
328
|
contact_point_parser = ContactPointApiParser()
|
|
330
329
|
|
|
@@ -361,27 +360,8 @@ suggest_parser = api.parser()
|
|
|
361
360
|
suggest_parser.add_argument(
|
|
362
361
|
"q", help="The string to autocomplete/suggest", location="args", required=True
|
|
363
362
|
)
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
def suggest_size(value: str) -> Optional[int]:
|
|
367
|
-
"""Parse an integer that must be between 1 and 20."""
|
|
368
|
-
help_message = "The size must be an integer between 1 and 20."
|
|
369
|
-
try:
|
|
370
|
-
parsed = int(value)
|
|
371
|
-
except ValueError:
|
|
372
|
-
raise ValueError(help_message)
|
|
373
|
-
|
|
374
|
-
if parsed < 1 or parsed > 20:
|
|
375
|
-
raise ValueError(help_message)
|
|
376
|
-
return parsed
|
|
377
|
-
|
|
378
|
-
|
|
379
363
|
suggest_parser.add_argument(
|
|
380
|
-
"size",
|
|
381
|
-
type=suggest_size,
|
|
382
|
-
help="The amount of suggestion to fetch (between 1 and 20)",
|
|
383
|
-
location="args",
|
|
384
|
-
default=10,
|
|
364
|
+
"size", type=int, help="The amount of suggestion to fetch", location="args", default=10
|
|
385
365
|
)
|
|
386
366
|
|
|
387
367
|
|
udata/core/user/metrics.py
CHANGED
udata/cors.py
CHANGED
|
@@ -15,10 +15,10 @@ def add_vary(headers: Headers, header: str):
|
|
|
15
15
|
|
|
16
16
|
def add_actual_request_headers(headers: Headers) -> Headers:
|
|
17
17
|
origin = request.headers.get("Origin", None)
|
|
18
|
-
add_vary(headers, "Origin")
|
|
19
|
-
|
|
20
18
|
if origin:
|
|
21
19
|
headers.set("Access-Control-Allow-Origin", origin)
|
|
20
|
+
add_vary(headers, "Origin")
|
|
21
|
+
|
|
22
22
|
headers.set("Access-Control-Allow-Credentials", "true")
|
|
23
23
|
|
|
24
24
|
return headers
|
|
@@ -41,10 +41,10 @@ def is_allowed_cors_route():
|
|
|
41
41
|
|
|
42
42
|
def add_preflight_request_headers(headers: Headers) -> Headers:
|
|
43
43
|
origin = request.headers.get("Origin", None)
|
|
44
|
-
add_vary(headers, "Origin")
|
|
45
|
-
|
|
46
44
|
if origin:
|
|
47
45
|
headers.set("Access-Control-Allow-Origin", origin)
|
|
46
|
+
add_vary(headers, "Origin")
|
|
47
|
+
|
|
48
48
|
headers.set("Access-Control-Allow-Credentials", "true")
|
|
49
49
|
|
|
50
50
|
# The API allows all methods, so just copy the browser requested methods from the request headers.
|
udata/features/transfer/api.py
CHANGED
|
@@ -3,6 +3,7 @@ from flask import request
|
|
|
3
3
|
from udata.api import API, api, base_reference, fields
|
|
4
4
|
from udata.core.dataset.api_fields import dataset_ref_fields
|
|
5
5
|
from udata.core.organization.api_fields import org_ref_fields
|
|
6
|
+
from udata.core.reuse.api_fields import reuse_ref_fields
|
|
6
7
|
from udata.core.user.api_fields import user_ref_fields
|
|
7
8
|
from udata.models import Dataset, Organization, Reuse, User, db
|
|
8
9
|
from udata.utils import id_or_404
|
|
@@ -46,7 +47,7 @@ person_mapping = {
|
|
|
46
47
|
|
|
47
48
|
subject_mapping = {
|
|
48
49
|
Dataset: dataset_ref_fields,
|
|
49
|
-
Reuse:
|
|
50
|
+
Reuse: reuse_ref_fields,
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
transfer_fields = api.model(
|
udata/harvest/actions.py
CHANGED
|
@@ -177,7 +177,7 @@ def purge_jobs():
|
|
|
177
177
|
bucket = current_app.config.get("HARVEST_GRAPHS_S3_BUCKET")
|
|
178
178
|
if bucket is None:
|
|
179
179
|
log.error(
|
|
180
|
-
"Bucket isn't configured anymore, but jobs still exist with external filenames. Could not delete them."
|
|
180
|
+
f"Bucket isn't configured anymore, but jobs still exist with external filenames. Could not delete them."
|
|
181
181
|
)
|
|
182
182
|
break
|
|
183
183
|
|
udata/harvest/tasks.py
CHANGED
udata/harvest/tests/factories.py
CHANGED
|
@@ -3,6 +3,8 @@ import pytest
|
|
|
3
3
|
from factory.fuzzy import FuzzyChoice
|
|
4
4
|
from flask.signals import Namespace
|
|
5
5
|
|
|
6
|
+
from udata.core.dataset.factories import DatasetFactory
|
|
7
|
+
from udata.core.dataset.models import Dataset
|
|
6
8
|
from udata.factories import ModelFactory
|
|
7
9
|
|
|
8
10
|
from .. import backends
|
|
@@ -4,6 +4,7 @@ import re
|
|
|
4
4
|
import xml.etree.ElementTree as ET
|
|
5
5
|
from datetime import date
|
|
6
6
|
|
|
7
|
+
import boto3
|
|
7
8
|
import pytest
|
|
8
9
|
from flask import current_app
|
|
9
10
|
|
|
@@ -244,7 +245,7 @@ class DcatBackendTest:
|
|
|
244
245
|
|
|
245
246
|
datasets = {d.harvest.dct_identifier: d for d in Dataset.objects}
|
|
246
247
|
|
|
247
|
-
assert datasets["1"].schema
|
|
248
|
+
assert datasets["1"].schema == None
|
|
248
249
|
resources_by_title = {resource["title"]: resource for resource in datasets["1"].resources}
|
|
249
250
|
|
|
250
251
|
# Schema with wrong version are considered as external. Maybe we could change this in the future
|
|
@@ -252,8 +253,8 @@ class DcatBackendTest:
|
|
|
252
253
|
resources_by_title["Resource 1-2"].schema.url
|
|
253
254
|
== "https://schema.data.gouv.fr/schemas/etalab/schema-irve-statique/1337.42.0/schema-statique.json"
|
|
254
255
|
)
|
|
255
|
-
assert resources_by_title["Resource 1-2"].schema.name
|
|
256
|
-
assert resources_by_title["Resource 1-2"].schema.version
|
|
256
|
+
assert resources_by_title["Resource 1-2"].schema.name == None
|
|
257
|
+
assert resources_by_title["Resource 1-2"].schema.version == None
|
|
257
258
|
|
|
258
259
|
assert datasets["2"].schema.name == "RGF93 / Lambert-93 (EPSG:2154)"
|
|
259
260
|
assert (
|
|
@@ -265,17 +266,17 @@ class DcatBackendTest:
|
|
|
265
266
|
# Unknown schema are kept as they were provided
|
|
266
267
|
assert resources_by_title["Resource 2-1"].schema.name == "Example Schema"
|
|
267
268
|
assert resources_by_title["Resource 2-1"].schema.url == "https://example.org/schema.json"
|
|
268
|
-
assert resources_by_title["Resource 2-1"].schema.version
|
|
269
|
+
assert resources_by_title["Resource 2-1"].schema.version == None
|
|
269
270
|
|
|
270
|
-
assert resources_by_title["Resource 2-2"].schema
|
|
271
|
+
assert resources_by_title["Resource 2-2"].schema == None
|
|
271
272
|
|
|
272
|
-
assert datasets["3"].schema
|
|
273
|
+
assert datasets["3"].schema == None
|
|
273
274
|
resources_by_title = {resource["title"]: resource for resource in datasets["3"].resources}
|
|
274
275
|
|
|
275
276
|
# If there is just the URL, and it matches a known schema inside the catalog, only set the name and the version
|
|
276
277
|
# (discard the URL)
|
|
277
278
|
assert resources_by_title["Resource 3-1"].schema.name == "etalab/schema-irve-statique"
|
|
278
|
-
assert resources_by_title["Resource 3-1"].schema.url
|
|
279
|
+
assert resources_by_title["Resource 3-1"].schema.url == None
|
|
279
280
|
assert resources_by_title["Resource 3-1"].schema.version == "2.2.0"
|
|
280
281
|
|
|
281
282
|
job = HarvestJob.objects.order_by("-id").first()
|
|
@@ -320,7 +321,7 @@ class DcatBackendTest:
|
|
|
320
321
|
|
|
321
322
|
datasets = {d.harvest.dct_identifier: d for d in Dataset.objects}
|
|
322
323
|
|
|
323
|
-
assert datasets["1"].spatial
|
|
324
|
+
assert datasets["1"].spatial == None
|
|
324
325
|
assert datasets["2"].spatial.geom == {
|
|
325
326
|
"type": "MultiPolygon",
|
|
326
327
|
"coordinates": [
|
|
@@ -329,7 +330,7 @@ class DcatBackendTest:
|
|
|
329
330
|
[[[159, -25.0], [159, -11], [212, -11], [212, -25.0], [159, -25.0]]],
|
|
330
331
|
],
|
|
331
332
|
}
|
|
332
|
-
assert datasets["3"].spatial
|
|
333
|
+
assert datasets["3"].spatial == None
|
|
333
334
|
|
|
334
335
|
@pytest.mark.options(SCHEMA_CATALOG_URL="https://example.com/schemas")
|
|
335
336
|
def test_harvest_schemas(self, rmock):
|
|
@@ -344,7 +345,7 @@ class DcatBackendTest:
|
|
|
344
345
|
|
|
345
346
|
datasets = {d.harvest.dct_identifier: d for d in Dataset.objects}
|
|
346
347
|
|
|
347
|
-
assert datasets["1"].schema
|
|
348
|
+
assert datasets["1"].schema == None
|
|
348
349
|
resources_by_title = {resource["title"]: resource for resource in datasets["1"].resources}
|
|
349
350
|
|
|
350
351
|
# Schema with wrong version are considered as external. Maybe we could change this in the future
|
|
@@ -352,8 +353,8 @@ class DcatBackendTest:
|
|
|
352
353
|
resources_by_title["Resource 1-2"].schema.url
|
|
353
354
|
== "https://schema.data.gouv.fr/schemas/etalab/schema-irve-statique/1337.42.0/schema-statique.json"
|
|
354
355
|
)
|
|
355
|
-
assert resources_by_title["Resource 1-2"].schema.name
|
|
356
|
-
assert resources_by_title["Resource 1-2"].schema.version
|
|
356
|
+
assert resources_by_title["Resource 1-2"].schema.name == None
|
|
357
|
+
assert resources_by_title["Resource 1-2"].schema.version == None
|
|
357
358
|
|
|
358
359
|
assert datasets["2"].schema.name == "RGF93 / Lambert-93 (EPSG:2154)"
|
|
359
360
|
assert (
|
|
@@ -365,17 +366,17 @@ class DcatBackendTest:
|
|
|
365
366
|
# Unknown schema are kept as they were provided
|
|
366
367
|
assert resources_by_title["Resource 2-1"].schema.name == "Example Schema"
|
|
367
368
|
assert resources_by_title["Resource 2-1"].schema.url == "https://example.org/schema.json"
|
|
368
|
-
assert resources_by_title["Resource 2-1"].schema.version
|
|
369
|
+
assert resources_by_title["Resource 2-1"].schema.version == None
|
|
369
370
|
|
|
370
|
-
assert resources_by_title["Resource 2-2"].schema
|
|
371
|
+
assert resources_by_title["Resource 2-2"].schema == None
|
|
371
372
|
|
|
372
|
-
assert datasets["3"].schema
|
|
373
|
+
assert datasets["3"].schema == None
|
|
373
374
|
resources_by_title = {resource["title"]: resource for resource in datasets["3"].resources}
|
|
374
375
|
|
|
375
376
|
# If there is just the URL, and it matches a known schema inside the catalog, only set the name and the version
|
|
376
377
|
# (discard the URL)
|
|
377
378
|
assert resources_by_title["Resource 3-1"].schema.name == "etalab/schema-irve-statique"
|
|
378
|
-
assert resources_by_title["Resource 3-1"].schema.url
|
|
379
|
+
assert resources_by_title["Resource 3-1"].schema.url == None
|
|
379
380
|
assert resources_by_title["Resource 3-1"].schema.version == "2.2.0"
|
|
380
381
|
|
|
381
382
|
def test_simple_nested_attributes(self, rmock):
|
|
@@ -18,7 +18,7 @@ def migrate(db):
|
|
|
18
18
|
oauth_clients = db.oauth2_client
|
|
19
19
|
oauth_clients.update_many({}, {"$rename": {"scopes": "scope"}})
|
|
20
20
|
for client in oauth_clients.find():
|
|
21
|
-
if type(client["scope"])
|
|
21
|
+
if type(client["scope"]) == list:
|
|
22
22
|
scope_str = " ".join(client["scope"])
|
|
23
23
|
client["scope"] = scope_str
|
|
24
24
|
oauth_clients.save(client)
|
udata/mongo/datetime_fields.py
CHANGED
|
@@ -6,7 +6,6 @@ from mongoengine import EmbeddedDocument
|
|
|
6
6
|
from mongoengine.fields import BaseField, DateTimeField
|
|
7
7
|
from mongoengine.signals import pre_save
|
|
8
8
|
|
|
9
|
-
from udata.api_fields import field
|
|
10
9
|
from udata.i18n import lazy_gettext as _
|
|
11
10
|
|
|
12
11
|
log = logging.getLogger(__name__)
|
|
@@ -56,17 +55,11 @@ class DateRange(EmbeddedDocument):
|
|
|
56
55
|
|
|
57
56
|
|
|
58
57
|
class Datetimed(object):
|
|
59
|
-
created_at =
|
|
60
|
-
|
|
61
|
-
sortable="created",
|
|
62
|
-
readonly=True,
|
|
58
|
+
created_at = DateTimeField(
|
|
59
|
+
verbose_name=_("Creation date"), default=datetime.utcnow, required=True
|
|
63
60
|
)
|
|
64
|
-
last_modified =
|
|
65
|
-
|
|
66
|
-
verbose_name=_("Last modification date"), default=datetime.utcnow, required=True
|
|
67
|
-
),
|
|
68
|
-
sortable=True,
|
|
69
|
-
readonly=True,
|
|
61
|
+
last_modified = DateTimeField(
|
|
62
|
+
verbose_name=_("Last modification date"), default=datetime.utcnow, required=True
|
|
70
63
|
)
|
|
71
64
|
|
|
72
65
|
|
udata/mongo/document.py
CHANGED
|
@@ -11,8 +11,6 @@ log = logging.getLogger(__name__)
|
|
|
11
11
|
def serialize(value):
|
|
12
12
|
if hasattr(value, "to_dict"):
|
|
13
13
|
return value.to_dict()
|
|
14
|
-
elif isinstance(value, dict):
|
|
15
|
-
return {key: serialize(val) for key, val in value.items()}
|
|
16
14
|
elif isinstance(value, Iterable) and not isinstance(value, str):
|
|
17
15
|
return [serialize(val) for val in value]
|
|
18
16
|
else:
|
udata/mongo/taglist_field.py
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
from mongoengine.fields import ListField, StringField
|
|
2
2
|
from slugify import slugify
|
|
3
3
|
|
|
4
|
-
from udata import tags
|
|
5
|
-
from udata.i18n import lazy_gettext as _
|
|
6
|
-
|
|
7
4
|
|
|
8
5
|
class TagListField(ListField):
|
|
9
6
|
def __init__(self, **kwargs):
|
|
10
7
|
self.tags = []
|
|
11
8
|
super(TagListField, self).__init__(StringField(), **kwargs)
|
|
12
9
|
|
|
13
|
-
@staticmethod
|
|
14
|
-
def from_input(input):
|
|
15
|
-
if isinstance(input, list):
|
|
16
|
-
return [tags.slug(value) for value in input]
|
|
17
|
-
elif isinstance(input, str):
|
|
18
|
-
return tags.tags_list(input)
|
|
19
|
-
else:
|
|
20
|
-
return []
|
|
21
|
-
|
|
22
10
|
def clean(self, value):
|
|
23
11
|
return sorted(list(set([slugify(v, to_lower=True) for v in value])))
|
|
24
12
|
|
|
@@ -27,17 +15,3 @@ class TagListField(ListField):
|
|
|
27
15
|
|
|
28
16
|
def to_mongo(self, value):
|
|
29
17
|
return super(TagListField, self).to_mongo(self.clean(value))
|
|
30
|
-
|
|
31
|
-
def validate(self, values):
|
|
32
|
-
super(TagListField, self).validate(values)
|
|
33
|
-
|
|
34
|
-
for tag in values:
|
|
35
|
-
if not tags.MIN_TAG_LENGTH <= len(tag) <= tags.MAX_TAG_LENGTH:
|
|
36
|
-
self.error(
|
|
37
|
-
_(
|
|
38
|
-
'Tag "%(tag)s" must be between %(min)d ' "and %(max)d characters long.",
|
|
39
|
-
min=tags.MIN_TAG_LENGTH,
|
|
40
|
-
max=tags.MAX_TAG_LENGTH,
|
|
41
|
-
tag=tag,
|
|
42
|
-
)
|
|
43
|
-
)
|
udata/search/commands.py
CHANGED
|
@@ -93,7 +93,7 @@ def finalize_reindex(models, start):
|
|
|
93
93
|
r = requests.post(url, json=payload)
|
|
94
94
|
r.raise_for_status()
|
|
95
95
|
except Exception:
|
|
96
|
-
log.exception("Unable to set alias for index")
|
|
96
|
+
log.exception(f"Unable to set alias for index")
|
|
97
97
|
|
|
98
98
|
modified_since_reindex = 0
|
|
99
99
|
for adapter in iter_adapters():
|
udata/search/query.py
CHANGED
udata/settings.py
CHANGED
|
@@ -522,7 +522,6 @@ class Defaults(object):
|
|
|
522
522
|
FIXTURE_DATASET_SLUGS = []
|
|
523
523
|
PUBLISH_ON_RESOURCE_EVENTS = False
|
|
524
524
|
RESOURCES_ANALYSER_URI = "http://localhost:8000"
|
|
525
|
-
RESOURCES_ANALYSER_API_KEY = None
|
|
526
525
|
|
|
527
526
|
# Datasets quality settings
|
|
528
527
|
###########################################################################
|