-
Notifications
You must be signed in to change notification settings - Fork 199
chore: new email flow fix #1483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideMakes the order-level email field configurable (asked/required), adapts checkout/contact/confirmation flows to respect these settings, and exposes the new options in settings validation, forms, API, and UI. Sequence diagram for configurable order email flow in checkoutsequenceDiagram
actor Buyer
participant Browser
participant ContactForm
participant QuestionsStep
participant CartSession
participant ConfirmStep
participant EventSettings
Buyer->>Browser: Open checkout contact/questions step
Browser->>QuestionsStep: GET questions_step
QuestionsStep->>EventSettings: Read order_email_asked, order_email_required, order_email_asked_twice
QuestionsStep->>ContactForm: Initialize(event, request, all_optional)
ContactForm->>EventSettings: Check order_email_asked
alt order_email_asked_true
ContactForm->>ContactForm: Add email field (required_based_on_order_email_required)
ContactForm->>EventSettings: Check order_email_asked_twice
alt order_email_asked_twice_true
ContactForm->>ContactForm: Add email_repeat field
end
else order_email_asked_false
ContactForm->>ContactForm: Do_not_add_email_field
end
QuestionsStep-->>Browser: Render form (email field maybe present)
Buyer->>Browser: Fill form and submit
Browser->>QuestionsStep: POST questions_step
QuestionsStep->>ContactForm: Validate form
alt form_invalid
QuestionsStep-->>Browser: Re_render_with_errors
else form_valid
alt email_in_cleaned_data
QuestionsStep->>CartSession: Set email from cleaned_data
else no_email_in_cleaned_data
QuestionsStep->>CartSession: Remove email key
end
QuestionsStep-->>Browser: Redirect to next step
end
Buyer->>Browser: Open confirmation step
Browser->>ConfirmStep: GET confirm_step
ConfirmStep->>CartSession: Read contact_form_data.email
alt email_present_and_not_none_value
ConfirmStep-->>Browser: Show email in contact_info
else no_email
ConfirmStep-->>Browser: Show confirmation without email
end
Class diagram for Event settings and checkout email handlingclassDiagram
class EventSettings {
bool order_email_asked
bool order_email_required
bool order_email_asked_twice
bool order_phone_asked
bool order_phone_required
bool attendee_emails_asked
bool attendee_emails_required
}
class ContactForm {
+bool all_optional
+Event event
+HttpRequest request
+EmailField email
+EmailField email_repeat
+CharField wikimedia_username
+__init__(args, kwargs, event, request, all_optional)
+clean()
}
class QuestionsStep {
+dict cart_session
+HttpRequest request
+bool all_optional
+bool address_asked
+contact_form()
+post(request)
+is_completed(request, warn)
}
class ConfirmStep {
+dict cart_session
+get_context_data(kwargs)
}
class SettingsValidator {
+validate_event_settings(event, settings_dict)
}
EventSettings <.. ContactForm : reads
EventSettings <.. QuestionsStep : reads
EventSettings <.. ConfirmStep : reads
SettingsValidator <.. EventSettings : validates
QuestionsStep --> ContactForm : creates
QuestionsStep --> ConfirmStep : precedes
QuestionsStep --> cart_session : stores_email
ConfirmStep --> cart_session : reads_email
class EventSettingsForm {
+bool order_email_asked
+bool order_email_required
+bool order_email_asked_twice
+fields
}
class EventSettingsSerializer {
+bool order_email_asked
+bool order_email_required
+bool order_email_asked_twice
+fields
}
EventSettingsForm <.. EventSettings : configures
EventSettingsSerializer <.. EventSettings : serializes
SettingsValidator --> EventSettingsForm : uses_values
SettingsValidator --> EventSettingsSerializer : uses_values
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and found some issues that need to be addressed.
- In
pretixcontrol/event/settings.htmlyou rendersform.order_email_asked_required, but the settings and form only defineorder_email_askedandorder_email_required, so this should be updated to use the existing fields (or a combined virtual field) to avoid a template error.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `pretixcontrol/event/settings.html` you render `sform.order_email_asked_required`, but the settings and form only define `order_email_asked` and `order_email_required`, so this should be updated to use the existing fields (or a combined virtual field) to avoid a template error.
## Individual Comments
### Comment 1
<location> `app/eventyay/control/templates/pretixcontrol/event/settings.html:54` </location>
<code_context>
- </div>
- </div>
- </div>
+ {% bootstrap_field sform.order_email_asked_required layout="control" %}
{% bootstrap_field sform.order_email_asked_twice layout="control" %}
{% bootstrap_field sform.include_wikimedia_username layout="control" %}
</code_context>
<issue_to_address>
**issue (bug_risk):** The template refers to `sform.order_email_asked_required`, but the settings and form only define `order_email_asked` and `order_email_required`.
`default_settings.py` and `EventSettingsForm` only define `order_email_asked` and `order_email_required`, so `sform.order_email_asked_required` will not exist and will break rendering or hide these options. Please render the two actual fields instead (e.g., separate `bootstrap_field` calls for `sform.order_email_asked` and `sform.order_email_required`).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
app/eventyay/control/templates/pretixcontrol/event/settings.html
Outdated
Show resolved
Hide resolved
215d808 to
409a70a
Compare
mariobehling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Please add screenshots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR makes order-level email collection configurable by introducing two new event settings: order_email_asked (whether to ask for order email) and order_email_required (whether it's mandatory). Previously, order email was always required. This change enables events to make email optional or skip it entirely.
Key changes:
- Added
order_email_askedandorder_email_requiredsettings with corresponding validation - Refactored checkout form to dynamically add email fields based on settings
- Updated checkout flow to guard email field access and handle optional email scenarios
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/eventyay/presale/forms/checkout.py | Email and email_repeat fields now added dynamically based on event settings instead of being hardcoded |
| app/eventyay/presale/checkoutflowstep/questions_step.py | Added guards for email field access and conditional email validation in completion checks |
| app/eventyay/presale/checkoutflowstep/confirm_step.py | Email display now conditional on email being present and not a sentinel value |
| app/eventyay/control/templates/pretixcontrol/event/settings.html | UI updated to show new order email settings (asked/required) or combined virtual field |
| app/eventyay/control/forms/event.py | New settings added to EventSettingsForm auto_fields list |
| app/eventyay/base/settings.py | Validation added to ensure order_email_required cannot be enabled without order_email_asked |
| app/eventyay/base/configurations/default_setting.py | Defined order_email_asked and order_email_required settings with defaults, labels, and help text |
| app/eventyay/api/serializers/event.py | Exposed new order email settings in API serializer |
Comments suppressed due to low confidence (2)
app/eventyay/base/configurations/default_setting.py:215
- The order_email_asked_twice setting should have a validation check or dependency attribute to ensure it can only be enabled when order_email_asked is also enabled. Without this, users could enable "ask twice" while disabling "ask", which would be confusing even though the code handles it safely.
'order_email_asked_twice': {
'default': 'False',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_('Ask for the order email address twice'),
help_text=_('Require attendees to enter their primary email address twice to help prevent errors.'),
),
},
app/eventyay/presale/forms/checkout.py:71
- When adding the email_repeat field, its required attribute should be set to match the email field's required attribute (email_required). Currently, it defaults to True (EmailField default), but should be explicitly set to email_required for consistency with the email field.
self.fields['email_repeat'] = forms.EmailField(
label=_('E-mail address (repeated)'),
help_text=_('Please enter the same email address again to make sure you typed it correctly.'),
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>

Fixes #1480
Summary by Sourcery
Make order-level email collection configurable and adapt checkout flow to optional or required email addresses.
New Features:
Bug Fixes:
Enhancements: