Add fields to team forms (#1615)

* Adds custom fields for teams
* Closes #756
This commit is contained in:
Kevin Chung
2020-08-21 02:49:28 -04:00
committed by GitHub
parent fb454b8262
commit c1672d1506
31 changed files with 1054 additions and 123 deletions

View File

@@ -130,7 +130,7 @@ def test_fields_properties():
resp = r.get_json()
assert resp == {
"success": False,
"errors": {"fields": ["Field CustomField4 cannot be editted"]},
"errors": {"fields": ["Field 'CustomField4' cannot be editted"]},
}
r = client.patch(
@@ -166,25 +166,24 @@ def test_boolean_checkbox_field():
with app.app_context():
gen_field(app.db, name="CustomField1", field_type="boolean", required=False)
with app.app_context():
with app.test_client() as client:
r = client.get("/register")
resp = r.get_data(as_text=True)
with app.test_client() as client:
r = client.get("/register")
resp = r.get_data(as_text=True)
# We should have rendered a checkbox input
assert "checkbox" in resp
# We should have rendered a checkbox input
assert "checkbox" in resp
with client.session_transaction() as sess:
data = {
"name": "user",
"email": "user@ctfd.io",
"password": "password",
"nonce": sess.get("nonce"),
"fields[1]": "y",
}
client.post("/register", data=data)
with client.session_transaction() as sess:
assert sess["id"]
with client.session_transaction() as sess:
data = {
"name": "user",
"email": "user@ctfd.io",
"password": "password",
"nonce": sess.get("nonce"),
"fields[1]": "y",
}
client.post("/register", data=data)
with client.session_transaction() as sess:
assert sess["id"]
assert UserFieldEntries.query.count() == 1
assert UserFieldEntries.query.filter_by(id=1).first().value is True
@@ -196,7 +195,7 @@ def test_boolean_checkbox_field():
assert "checkbox" in resp
r = client.patch(
"/api/v1/users/me", json={"fields": [{"field_id": 1, "value": False}]},
"/api/v1/users/me", json={"fields": [{"field_id": 1, "value": False}]}
)
assert r.status_code == 200
assert UserFieldEntries.query.count() == 1