udata 9.2.2.dev31762__py2.py3-none-any.whl → 9.2.2.dev31791__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/static/chunks/{5.9049c2001a2f21930f78.js → 5.4e4ddeee32090f1f2af6.js} +3 -3
- udata/static/chunks/{5.9049c2001a2f21930f78.js.map → 5.4e4ddeee32090f1f2af6.js.map} +1 -1
- udata/static/chunks/{6.ad092769b0983a6eec2a.js → 6.41b17f3ca439d5ec2b1e.js} +3 -3
- udata/static/chunks/{6.ad092769b0983a6eec2a.js.map → 6.41b17f3ca439d5ec2b1e.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/tests/api/test_contact_points.py +40 -1
- udata/translations/udata.pot +89 -93
- {udata-9.2.2.dev31762.dist-info → udata-9.2.2.dev31791.dist-info}/METADATA +2 -1
- {udata-9.2.2.dev31762.dist-info → udata-9.2.2.dev31791.dist-info}/RECORD +17 -17
- {udata-9.2.2.dev31762.dist-info → udata-9.2.2.dev31791.dist-info}/LICENSE +0 -0
- {udata-9.2.2.dev31762.dist-info → udata-9.2.2.dev31791.dist-info}/WHEEL +0 -0
- {udata-9.2.2.dev31762.dist-info → udata-9.2.2.dev31791.dist-info}/entry_points.txt +0 -0
- {udata-9.2.2.dev31762.dist-info → udata-9.2.2.dev31791.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)
|