Skip to content

Commit 6d86581

Browse files
Merge pull request #426 from peopledoc/fix-conditions-default-value
Fix conditions default value
2 parents 60a1497 + 7c9aa26 commit 6d86581

File tree

8 files changed

+58
-79
lines changed

8 files changed

+58
-79
lines changed

.circleci/config.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ jobs:
1313
command: "apt-get update"
1414
- run:
1515
name: "Install postgresql-common Debian package"
16-
command: "apt-get install -y postgresql-common"
16+
command: "apt-get install -y postgresql postgresql-common"
1717
- checkout
1818
- run:
1919
name: Run the test suite
20-
command: tox -r
20+
command: |
21+
chmod 777 /tmp
22+
tox -r
2123
2224
docs:
2325
working_directory: ~/django-formidable
@@ -29,11 +31,11 @@ jobs:
2931
name: Check Python version & install Python dependencies
3032
command: |
3133
python3 --version
32-
sudo apt update && sudo apt install python-pip python-dev
34+
sudo apt update && sudo apt install python3-pip python3-dev
3335
- run:
3436
name: Run Sphinx doc tests using tox
3537
command: |
36-
pip install --user tox
38+
python3 -m pip install --user tox
3739
~/.local/bin/tox -e docs
3840
3941
workflows:

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ ChangeLog
55
master (unreleased)
66
==================
77

8-
Nothing to see here.
8+
- Fix issues with postgresql on CI.
9+
- Replace deprecated yaml.load calls to fix doc build.
10+
- Add a default value `[]` to conditions.
911

1012
Release 7.1.0 (2021-06-28)
1113
==========================

demo/tests/serializers/test_formidable_serializer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ def test_custom_field_serialize_contextserializer(self):
111111
# remove instance
112112
instance.delete()
113113

114+
def test_custom_field_serialize_default_conditions(self):
115+
serializer = FormidableSerializer(data=self.schema)
116+
assert serializer.is_valid()
117+
118+
self.assertIn("conditions", serializer.validated_data)
119+
self.assertEqual(serializer.validated_data["conditions"], [])
120+
121+
def test_custom_field_serialize_none_conditions(self):
122+
self.schema["conditions"] = None
123+
serializer = FormidableSerializer(data=self.schema)
124+
assert not serializer.is_valid()
125+
126+
self.assertIn(
127+
"This field may not be null.",
128+
serializer.errors["conditions"])
129+
114130
def test_context_in_field_serializer(self):
115131
# backup a serializer
116132
backup_serializer = self.field_register[self.custom_type_id]

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,4 @@ collectstatic:
241241
cp \
242242
node_modules/swagger-ui-dist/* \
243243
source/_static/swagger-ui/
244-
python -c 'import yaml, json; json.dump(yaml.load(open("./swagger/formidable.yml")), open("./source/_static/specs/formidable.json", "w"), indent=4, separators=(",", ": "), sort_keys=True)'
244+
python -c 'import yaml, json; json.dump(yaml.full_load(open("./swagger/formidable.yml")), open("./source/_static/specs/formidable.json", "w"), indent=4, separators=(",", ": "), sort_keys=True)'

docs/package-lock.json

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,18 @@
11
{
2-
"_args": [
3-
[
4-
5-
"/home/novapost/Projets/PeopleAsk/Dependencies/django-formidable/docs"
6-
]
7-
],
8-
"_development": true,
9-
"_from": "[email protected]",
10-
11-
"_inBundle": false,
12-
"_integrity": "sha512-5uAjeEqV+zbtalBDXAIrkqUZwsUHYwvBSeGYlFcLj1ERS3jfprL4OPLSSriDoeXCtNmWzpz5aooV2qJW+DqdUQ==",
13-
"_location": "/swagger-ui-dist",
14-
"_phantomChildren": {},
15-
"_requested": {
16-
"type": "version",
17-
"registry": true,
18-
19-
"name": "swagger-ui-dist",
20-
"escapedName": "swagger-ui-dist",
21-
"rawSpec": "3.24.0",
22-
"saveSpec": null,
23-
"fetchSpec": "3.24.0"
24-
},
25-
"_requiredBy": [
26-
"#DEV:/"
27-
],
28-
"_resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.24.0.tgz",
29-
"_spec": "3.24.0",
30-
"_where": "/home/novapost/Projets/PeopleAsk/Dependencies/django-formidable/docs",
31-
"bugs": {
32-
"url": "https://github.com/swagger-api/swagger-ui/issues"
33-
},
2+
"name": "swagger-ui-dist",
3+
"version": "3.24.0",
4+
"main": "index.js",
5+
"repository": "[email protected]:swagger-api/swagger-ui.git",
346
"contributors": [
35-
{
36-
"url": "in alphabetical order"
37-
},
38-
{
39-
"name": "Anna Bodnia",
40-
"email": "[email protected]"
41-
},
42-
{
43-
"name": "Buu Nguyen",
44-
"email": "[email protected]"
45-
},
46-
{
47-
"name": "Josh Ponelat",
48-
"email": "[email protected]"
49-
},
50-
{
51-
"name": "Kyle Shockey",
52-
"email": "[email protected]"
53-
},
54-
{
55-
"name": "Robert Barnwell",
56-
"email": "[email protected]"
57-
},
58-
{
59-
"name": "Sahar Jafari",
60-
"email": "[email protected]"
61-
}
7+
"(in alphabetical order)",
8+
"Anna Bodnia <[email protected]>",
9+
"Buu Nguyen <[email protected]>",
10+
"Josh Ponelat <[email protected]>",
11+
"Kyle Shockey <[email protected]>",
12+
"Robert Barnwell <[email protected]>",
13+
"Sahar Jafari <[email protected]>"
6214
],
63-
"dependencies": {},
64-
"description": "[![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](http://badge.fury.io/js/swagger-ui-dist)",
65-
"devDependencies": {},
66-
"homepage": "https://github.com/swagger-api/swagger-ui#readme",
6715
"license": "Apache-2.0",
68-
"main": "index.js",
69-
"name": "swagger-ui-dist",
70-
"repository": {
71-
"type": "git",
72-
"url": "git+ssh://[email protected]/swagger-api/swagger-ui.git"
73-
},
74-
"version": "3.24.0"
16+
"dependencies": {},
17+
"devDependencies": {}
7518
}

docs/tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def dict_constructor(loader, node):
2828
# Building raw data out of the Swagger Formidable definition
2929
swagger_file = join(ROOT_PATH, '..', 'swagger', 'formidable.yml')
3030
with open(swagger_file) as fd:
31-
data = yaml.load(fd)
31+
data = yaml.full_load(fd)
3232

3333
to_exclude = (
3434
'BuilderForm', 'InputError', 'BuilderError', 'InputForm', 'InputField'

formidable/serializers/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ConditionSerializer(serializers.Serializer):
4848
class FormidableSerializer(WithNestedSerializer):
4949

5050
fields = fields.FieldSerializer(many=True)
51-
conditions = ConditionSerializer(many=True, required=False)
51+
conditions = ConditionSerializer(many=True, required=False, default=[])
5252

5353
nested_objects = ['fields']
5454

0 commit comments

Comments
 (0)