Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions app/blueprints/docs/surveystream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3687,9 +3687,9 @@ paths:
description: >-
The field type of the column. Can be one of
`personal_details`, `custom_field`, or `location`.
bulk_editable:
allow_null_values:
type: boolean
description: Whether the field is bulk editable or not
description: Whether the field allows null values or not
column_source:
type: string
description: >-
Expand All @@ -3698,7 +3698,6 @@ paths:
required:
- column_name
- column_type
- bulk_editable
- column_source
required:
- form_uid
Expand Down Expand Up @@ -3757,9 +3756,9 @@ paths:
description: >
The field type of the column. Can be one of
`personal_details`, `custom_field`, or `location`.
bulk_editable:
allow_null_values:
type: boolean
description: Whether the field is bulk editable or not.
description: Whether the field allows null values or not.
column_source:
type: string
description: >-
Expand Down Expand Up @@ -7382,13 +7381,12 @@ paths:
description: >-
The field type of the column. Can be one of
`basic_details`, `custom_field`, or `location`.
bulk_editable:
allow_null_values:
type: boolean
description: Whether the field is bulk editable or not
description: Whether the field allows null values or not
required:
- column_name
- column_type
- bulk_editable
filters:
type: array
description: >-
Expand Down Expand Up @@ -7459,9 +7457,9 @@ paths:
items:
type: object
properties:
bulk_editable:
allow_null_values:
type: boolean
description: Whether the field is bulk editable or not.
description: Whether the field allows null values or not.
column_name:
type: string
description: The field name of the column.
Expand Down
21 changes: 8 additions & 13 deletions app/blueprints/enumerators/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,12 @@ def bulk_update_enumerators(validated_payload):
}

for column in column_config:
if column.column_type != "location" and column.bulk_editable is True:
if column.column_type != "location" and column.column_name not in (
"enumerator_id",
"email",
"mobile_primary",
"name",
):
bulk_editable_fields[column.column_type].append(column.column_name)

personal_details_patch_keys = []
Expand Down Expand Up @@ -1264,23 +1269,13 @@ def update_enumerator_column_config(validated_payload):
db.session.flush()

for column in payload["column_config"]:
if not isinstance(column["bulk_editable"], bool):
return (
jsonify(
{
"success": False,
"errors": f"Field 'bulk_editable' must be a boolean",
}
),
422,
)

db.session.add(
EnumeratorColumnConfig(
form_uid=form_uid,
column_name=column["column_name"],
column_type=column["column_type"],
bulk_editable=column["bulk_editable"],
allow_null_values=column["allow_null_values"],
)
)

Expand Down Expand Up @@ -1323,7 +1318,7 @@ def get_enumerator_column_config(validated_query_params):
{
"column_name": column.column_name,
"column_type": column.column_type,
"bulk_editable": column.bulk_editable,
"allow_null_values": column.allow_null_values,
}
for column in column_config
]
Expand Down
12 changes: 7 additions & 5 deletions app/blueprints/enumerators/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from app import db
from app.blueprints.forms.models import Form
from app.blueprints.locations.models import Location
from sqlalchemy import CheckConstraint
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import backref
from sqlalchemy.ext.mutable import MutableDict
from sqlalchemy.orm import backref

from app import db
from app.blueprints.forms.models import Form
from app.blueprints.locations.models import Location


class Enumerator(db.Model):
"""
Expand Down Expand Up @@ -237,7 +239,7 @@ class EnumeratorColumnConfig(db.Model):
),
nullable=False,
)
bulk_editable = db.Column(db.Boolean(), nullable=False, default=False)
allow_null_values = db.Column(db.Boolean(), nullable=False, server_default="true")

__table_args__ = (
db.PrimaryKeyConstraint("form_uid", "column_name"),
Expand Down
Loading