Skip to content

Commit

Permalink
Remove mandatory email requirement from new participant form
Browse files Browse the repository at this point in the history
  • Loading branch information
vidya-ram committed Oct 5, 2023
1 parent 15d7f41 commit 087af7e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 10 deletions.
19 changes: 10 additions & 9 deletions funnel/forms/sync_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ class TicketParticipantForm(forms.Form):
)
email = forms.EmailField(
__("Email"),
validators=[forms.validators.DataRequired(), forms.validators.ValidEmail()],
filters=[forms.filters.strip()],
validators=[forms.validators.Optional(), forms.validators.ValidEmail()],
filters=[forms.filters.none_if_empty()],
)
phone = forms.StringField(
__("Phone number"),
Expand Down Expand Up @@ -219,13 +219,14 @@ def set_queries(self) -> None:
def validate(self, *args, **kwargs) -> bool:
"""Validate form."""
result = super().validate(*args, **kwargs)
with db.session.no_autoflush:
accountemail = AccountEmail.get(email=self.email.data)
if accountemail is not None:
self.user = accountemail.account
else:
self.user = None
return result
if self.email is not None:
with db.session.no_autoflush:
accountemail = AccountEmail.get(email=self.email.data)
if accountemail is not None:
self.user = accountemail.account
else:
self.user = None
return result


@TicketParticipant.forms('badge')
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/sync_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class TicketParticipant(EmailAddressMixin, UuidMixin, BaseMixin, Model):
"""A participant in one or more events, synced from an external ticket source."""

__tablename__ = 'ticket_participant'
__email_optional__ = False
__email_optional__ = True
__email_for__ = 'participant'

fullname = with_roles(
Expand Down
57 changes: 57 additions & 0 deletions migrations/versions/017c60414c03_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""empty message
Revision ID: 017c60414c03
Revises: 4f9ca10b7b9d
Create Date: 2023-10-05 15:08:34.540672
"""

from typing import Optional, Tuple, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '017c60414c03'
down_revision: str = '4f9ca10b7b9d'
branch_labels: Optional[Union[str, Tuple[str, ...]]] = None
depends_on: Optional[Union[str, Tuple[str, ...]]] = None


def upgrade(engine_name: str = '') -> None:
"""Upgrade all databases."""
# Do not modify. Edit `upgrade_` instead
globals().get(f'upgrade_{engine_name}', lambda: None)()


def downgrade(engine_name: str = '') -> None:
"""Downgrade all databases."""
# Do not modify. Edit `downgrade_` instead
globals().get(f'downgrade_{engine_name}', lambda: None)()





def upgrade_() -> None:
"""Upgrade default database."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('ticket_participant', schema=None) as batch_op:
batch_op.alter_column('email_address_id',
existing_type=sa.INTEGER(),
nullable=True)

# ### end Alembic commands ###


def downgrade_() -> None:
"""Downgrade default database."""
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('ticket_participant', schema=None) as batch_op:
batch_op.alter_column('email_address_id',
existing_type=sa.INTEGER(),
nullable=False)

# ### end Alembic commands ###

0 comments on commit 087af7e

Please sign in to comment.