udata 9.2.2.dev31715__py2.py3-none-any.whl → 9.2.2.dev31769__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/contact_point/api.py +6 -1
- udata/core/contact_point/forms.py +4 -1
- udata/core/contact_point/models.py +9 -1
- udata/core/dataservices/models.py +1 -4
- udata/tests/api/test_contact_points.py +40 -1
- {udata-9.2.2.dev31715.dist-info → udata-9.2.2.dev31769.dist-info}/METADATA +3 -1
- {udata-9.2.2.dev31715.dist-info → udata-9.2.2.dev31769.dist-info}/RECORD +11 -11
- {udata-9.2.2.dev31715.dist-info → udata-9.2.2.dev31769.dist-info}/LICENSE +0 -0
- {udata-9.2.2.dev31715.dist-info → udata-9.2.2.dev31769.dist-info}/WHEEL +0 -0
- {udata-9.2.2.dev31715.dist-info → udata-9.2.2.dev31769.dist-info}/entry_points.txt +0 -0
- {udata-9.2.2.dev31715.dist-info → udata-9.2.2.dev31769.dist-info}/top_level.txt +0 -0
udata/core/contact_point/api.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import mongoengine
|
|
2
|
+
|
|
1
3
|
from udata.api import API, api
|
|
2
4
|
from udata.api.parsers import ModelApiParser
|
|
3
5
|
|
|
@@ -29,7 +31,10 @@ class ContactPointsListAPI(API):
|
|
|
29
31
|
def post(self):
|
|
30
32
|
"""Creates a contact point"""
|
|
31
33
|
form = api.validate(ContactPointForm)
|
|
32
|
-
|
|
34
|
+
try:
|
|
35
|
+
contact_point = form.save()
|
|
36
|
+
except mongoengine.errors.ValidationError as e:
|
|
37
|
+
api.abort(400, e.message)
|
|
33
38
|
return contact_point, 201
|
|
34
39
|
|
|
35
40
|
|
|
@@ -12,6 +12,9 @@ class ContactPointForm(ModelForm):
|
|
|
12
12
|
_("Name"),
|
|
13
13
|
[validators.DataRequired(), validators.NoURLs(_("URLs not allowed in this field"))],
|
|
14
14
|
)
|
|
15
|
-
email = fields.StringField(_("Email"), [validators.
|
|
15
|
+
email = fields.StringField(_("Email"), [validators.optional(), validators.Email()])
|
|
16
|
+
contact_form = fields.URLField(
|
|
17
|
+
_("Contact form"), description=_("The organization web contact form")
|
|
18
|
+
)
|
|
16
19
|
owner = fields.CurrentUserField()
|
|
17
20
|
organization = fields.PublishAsField(_("Publish as"))
|
|
@@ -5,7 +5,15 @@ __all__ = ("ContactPoint",)
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class ContactPoint(db.Document, Owned):
|
|
8
|
-
email = db.StringField(max_length=255, required=True)
|
|
9
8
|
name = db.StringField(max_length=255, required=True)
|
|
9
|
+
email = db.StringField(max_length=255)
|
|
10
|
+
contact_form = db.URLField()
|
|
10
11
|
|
|
11
12
|
meta = {"queryset_class": OwnedQuerySet}
|
|
13
|
+
|
|
14
|
+
def validate(self, clean=True):
|
|
15
|
+
if not self.email and not self.contact_form:
|
|
16
|
+
raise db.ValidationError(
|
|
17
|
+
"At least an email or a contact form is required for a contact point"
|
|
18
|
+
)
|
|
19
|
+
return super().validate(clean=clean)
|
|
@@ -122,10 +122,7 @@ class Dataservice(WithMetrics, Owned, db.Document):
|
|
|
122
122
|
readonly=True,
|
|
123
123
|
)
|
|
124
124
|
description = field(db.StringField(default=""), description="In markdown")
|
|
125
|
-
base_api_url = field(
|
|
126
|
-
db.URLField(required=True),
|
|
127
|
-
sortable=True,
|
|
128
|
-
)
|
|
125
|
+
base_api_url = field(db.URLField(), sortable=True)
|
|
129
126
|
endpoint_description_url = field(db.URLField())
|
|
130
127
|
authorization_request_url = field(db.URLField())
|
|
131
128
|
availability = field(db.FloatField(min=0, max=100), example="99.99")
|
|
@@ -2,8 +2,10 @@ import pytest
|
|
|
2
2
|
from flask import url_for
|
|
3
3
|
|
|
4
4
|
from udata.core.contact_point.factories import ContactPointFactory
|
|
5
|
+
from udata.i18n import gettext as _
|
|
5
6
|
from udata.models import ContactPoint
|
|
6
|
-
from udata.tests.helpers import assert200, assert204
|
|
7
|
+
from udata.tests.helpers import assert200, assert201, assert204, assert400
|
|
8
|
+
from udata.utils import faker
|
|
7
9
|
|
|
8
10
|
pytestmark = [
|
|
9
11
|
pytest.mark.usefixtures("clean_db"),
|
|
@@ -13,6 +15,43 @@ pytestmark = [
|
|
|
13
15
|
class ContactPointAPITest:
|
|
14
16
|
modules = []
|
|
15
17
|
|
|
18
|
+
def test_contact_point_api_create(self, api):
|
|
19
|
+
api.login()
|
|
20
|
+
data = {"name": faker.word(), "email": faker.email(), "contact_form": faker.url()}
|
|
21
|
+
response = api.post(url_for("api.contact_points"), data=data)
|
|
22
|
+
assert201(response)
|
|
23
|
+
assert ContactPoint.objects.count() == 1
|
|
24
|
+
|
|
25
|
+
def test_contact_point_api_create_email_or_contact_form(self, api):
|
|
26
|
+
api.login()
|
|
27
|
+
data = {"name": faker.word(), "contact_form": faker.url()}
|
|
28
|
+
response = api.post(url_for("api.contact_points"), data=data)
|
|
29
|
+
assert201(response)
|
|
30
|
+
assert ContactPoint.objects.count() == 1
|
|
31
|
+
|
|
32
|
+
data = {"name": faker.word(), "email": faker.email()}
|
|
33
|
+
response = api.post(url_for("api.contact_points"), data=data)
|
|
34
|
+
assert201(response)
|
|
35
|
+
assert ContactPoint.objects.count() == 2
|
|
36
|
+
|
|
37
|
+
def test_contact_point_api_invalid_email(self, api):
|
|
38
|
+
api.login()
|
|
39
|
+
data = {"name": faker.word(), "email": faker.word()}
|
|
40
|
+
response = api.post(url_for("api.contact_points"), data=data)
|
|
41
|
+
assert400(response)
|
|
42
|
+
assert "email" in response.json["errors"]
|
|
43
|
+
assert ContactPoint.objects.count() == 0
|
|
44
|
+
|
|
45
|
+
def test_contact_point_missing_contact_information(self, api):
|
|
46
|
+
api.login()
|
|
47
|
+
data = {"name": faker.word()}
|
|
48
|
+
response = api.post(url_for("api.contact_points"), data=data)
|
|
49
|
+
assert400(response)
|
|
50
|
+
assert response.json["message"] == _(
|
|
51
|
+
"At least an email or a contact form is required for a contact point"
|
|
52
|
+
)
|
|
53
|
+
assert ContactPoint.objects.count() == 0
|
|
54
|
+
|
|
16
55
|
def test_contact_point_api_update(self, api):
|
|
17
56
|
api.login()
|
|
18
57
|
contact_point = ContactPointFactory()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: udata
|
|
3
|
-
Version: 9.2.2.
|
|
3
|
+
Version: 9.2.2.dev31769
|
|
4
4
|
Summary: Open data portal
|
|
5
5
|
Home-page: https://github.com/opendatateam/udata
|
|
6
6
|
Author: Opendata Team
|
|
@@ -143,6 +143,8 @@ It is collectively taken care of by members of the
|
|
|
143
143
|
- Add a filter on organization and document sort parameters in the `/discussions` endpoint [#3147](https://github.com/opendatateam/udata/pull/3147)
|
|
144
144
|
- Move discussion catalog creation and add fields [#3152](https://github.com/opendatateam/udata/pull/3152) and [#3154](https://github.com/opendatateam/udata/pull/3154)
|
|
145
145
|
- Add resources formats and harvest remote_url on dataset catalog [#3159](https://github.com/opendatateam/udata/pull/3159)
|
|
146
|
+
- Add contact form in contact point model [#3164](https://github.com/opendatateam/udata/pull/3164)
|
|
147
|
+
- Make base_api_url optional in dataservice [https://github.com/opendatateam/udata/pull/3163](#3163)
|
|
146
148
|
|
|
147
149
|
## 9.2.1 (2024-09-23)
|
|
148
150
|
|
|
@@ -74,15 +74,15 @@ udata/core/badges/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
|
74
74
|
udata/core/badges/tests/test_commands.py,sha256=KrzUsW4jtiFAvq6n83MkDXc1gung0XX8ditQfOXvomI,1364
|
|
75
75
|
udata/core/badges/tests/test_model.py,sha256=05bG0CLqOhedYNeqgI8oCBm7mnGMQUf1Z10OrFzcBgA,4859
|
|
76
76
|
udata/core/contact_point/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
|
-
udata/core/contact_point/api.py,sha256=
|
|
77
|
+
udata/core/contact_point/api.py,sha256=hK5fanw-QZvenqu2XQW5xKmhPNPGK6xplUWqaMy_Il4,1951
|
|
78
78
|
udata/core/contact_point/api_fields.py,sha256=w6DyfvaIrX12mwaCLjk6ioAt81-GuRxdv69bTAhar1U,970
|
|
79
79
|
udata/core/contact_point/factories.py,sha256=MWu3fbE6G84e-7_gtsM5OifZPxHFRWDjw__qjd5fwDc,248
|
|
80
|
-
udata/core/contact_point/forms.py,sha256=
|
|
81
|
-
udata/core/contact_point/models.py,sha256=
|
|
80
|
+
udata/core/contact_point/forms.py,sha256=ykdnfLPrY2awIis2Ms57Wj0zuhws7dNPFkLpnkq7sas,688
|
|
81
|
+
udata/core/contact_point/models.py,sha256=Peli1ZbNBLydbhh9kBc0gKYFMxMiwjQAIFIjNZHUqNc,600
|
|
82
82
|
udata/core/dataservices/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
83
|
udata/core/dataservices/api.py,sha256=uwKSwwZEskECTzt9ePaAbfpwx6DbEP0eE3Ovopo2DPk,4750
|
|
84
84
|
udata/core/dataservices/factories.py,sha256=LDk8vvG0zhW8J-ZX5LoJQDU13pqeIyjQ05muuMro_eA,876
|
|
85
|
-
udata/core/dataservices/models.py,sha256=
|
|
85
|
+
udata/core/dataservices/models.py,sha256=BFnfGPmhZM2mSnv4eIy_s67iTGUPTdOnYNpOpSFiDyo,8239
|
|
86
86
|
udata/core/dataservices/permissions.py,sha256=98zM_R4v2ZtRubflB7ajaVQz-DVc-pZBMgtKUYy34oI,169
|
|
87
87
|
udata/core/dataservices/rdf.py,sha256=l1vItR7jhaTxs5f6kU6MAR32uvRR233GDbp1hIUbP3k,4673
|
|
88
88
|
udata/core/dataservices/tasks.py,sha256=a43x1oKNF-EYmzM3O-8GQPJvZsgJmQiXOZx8Qti3M4E,960
|
|
@@ -601,7 +601,7 @@ udata/tests/api/__init__.py,sha256=y4sL7LD1-KwONHF0q_Rhk2W6BmGUlp7Uz2JnX3e27sk,1
|
|
|
601
601
|
udata/tests/api/test_activities_api.py,sha256=RjDDeNle3T-ydVnh6BRypqxAE_244-DXaKkuUCT0HVU,2823
|
|
602
602
|
udata/tests/api/test_auth_api.py,sha256=OMRlY0OQt60j5N4A-N3HdWTuffOjRlFHkz5a3jJFieI,25987
|
|
603
603
|
udata/tests/api/test_base_api.py,sha256=2w_vz0eEuq3P3aN-ByvxGc3VZAo7XtgatFfcrzf2uEU,2244
|
|
604
|
-
udata/tests/api/test_contact_points.py,sha256=
|
|
604
|
+
udata/tests/api/test_contact_points.py,sha256=jumil3faYa11KmSZgZgl592IrDqKcthHUjRv1zqWWn8,2702
|
|
605
605
|
udata/tests/api/test_dataservices_api.py,sha256=SoiAOv3q0z41iEYXkZwnvr9KzULtfD_MlIQkLcfdf-E,15337
|
|
606
606
|
udata/tests/api/test_datasets_api.py,sha256=LQAUaYY8Sj2HibHu6Qg1T46LlLxlPRa_aP0r1Z7A0jc,80614
|
|
607
607
|
udata/tests/api/test_fields.py,sha256=OW85Z5MES5HeWOpapeem8OvR1cIcrqW-xMWpdZO4LZ8,1033
|
|
@@ -698,9 +698,9 @@ udata/translations/pt/LC_MESSAGES/udata.mo,sha256=WpPzAqVd2Onv_kz45ULUySKPLrpjcc
|
|
|
698
698
|
udata/translations/pt/LC_MESSAGES/udata.po,sha256=18Op9RUITewoDRewlOdYzzq6gjsf1lsvepACV1d7zxs,44976
|
|
699
699
|
udata/translations/sr/LC_MESSAGES/udata.mo,sha256=NIYRNhVoETZUvIvWm3cCW7DtMBAnS2vXzZjMF5ZzD_c,28500
|
|
700
700
|
udata/translations/sr/LC_MESSAGES/udata.po,sha256=rQB-4V4WJ7bURj6g2j653vItr5TMHadcLQxec7_fDmg,51545
|
|
701
|
-
udata-9.2.2.
|
|
702
|
-
udata-9.2.2.
|
|
703
|
-
udata-9.2.2.
|
|
704
|
-
udata-9.2.2.
|
|
705
|
-
udata-9.2.2.
|
|
706
|
-
udata-9.2.2.
|
|
701
|
+
udata-9.2.2.dev31769.dist-info/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
|
702
|
+
udata-9.2.2.dev31769.dist-info/METADATA,sha256=lb21wiV4o0sr4pvv2hSACtkciLYjTZstoxbSxDlWL8E,131519
|
|
703
|
+
udata-9.2.2.dev31769.dist-info/WHEEL,sha256=DZajD4pwLWue70CAfc7YaxT1wLUciNBvN_TTcvXpltE,110
|
|
704
|
+
udata-9.2.2.dev31769.dist-info/entry_points.txt,sha256=3SKiqVy4HUqxf6iWspgMqH8d88Htk6KoLbG1BU-UddQ,451
|
|
705
|
+
udata-9.2.2.dev31769.dist-info/top_level.txt,sha256=39OCg-VWFWOq4gCKnjKNu-s3OwFlZIu_dVH8Gl6ndHw,12
|
|
706
|
+
udata-9.2.2.dev31769.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|