Skip to content

Commit c861b55

Browse files
committed
Handle empty user and participant names
Set default name for participants with no name in migration
1 parent a3e4adf commit c861b55

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Set interrrogation as default name for participants with no name
2+
3+
Revision ID: c1
4+
Revises: 30b5fe7b5949
5+
Create Date: 2025-07-01 12:14
6+
"""
7+
8+
from alembic import op
9+
10+
# revision identifiers, used by Alembic.
11+
revision = 'c1'
12+
down_revision = '30b5fe7b5949'
13+
branch_labels = None
14+
depends_on = None
15+
16+
17+
def upgrade():
18+
op.execute(
19+
"""
20+
UPDATE participants
21+
SET name = '?'
22+
WHERE name IS NULL OR name = '';
23+
"""
24+
)
25+
26+
27+
def downgrade():
28+
pass

newdle/schemas.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class ParticipantSchema(mm.Schema):
131131
)
132132
)
133133

134+
@validates('name')
135+
def name_not_empty(self, value):
136+
if not value or not value.strip():
137+
raise ValidationError('This field cannot be empty.')
138+
134139

135140
class RestrictedParticipantSchema(ParticipantSchema):
136141
class Meta:

0 commit comments

Comments
 (0)