-
Notifications
You must be signed in to change notification settings - Fork 121
feat(checkout-api): implement event-level checkout endpoint and improve search validation #824
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
base: development
Are you sure you want to change the base?
Conversation
Reviewer's GuideIntroduced a new EventCheckoutView to support bulk checkout of event attendees via API, improved check-in search behavior by requiring non-empty and length-restricted queries, adjusted BASE_PATH and CORS settings in configuration, and registered the corresponding route for the new endpoint. Sequence diagram for the new event-wide attendee checkout API endpointsequenceDiagram
actor APIClient as API Client
participant EventCheckoutView
participant Auth as Auth/User
participant Event
participant CheckinList
participant Position as OrderPosition
participant CheckinService as perform_checkin
APIClient->>EventCheckoutView: POST /organizers/{org}/events/{event}/checkout/
EventCheckoutView->>Auth: Validate permissions
EventCheckoutView->>Event: Get checkin lists
loop For each CheckinList
EventCheckoutView->>CheckinList: Get positions_inside
loop For each Position
EventCheckoutView->>CheckinService: perform_checkin(type=EXIT)
CheckinService-->>EventCheckoutView: Success/Error
end
end
EventCheckoutView->>Event: Log action 'pretix.event.checkout_all'
EventCheckoutView-->>APIClient: Response with checkout_count, errors
Class diagram for EventCheckoutView and related check-in logicclassDiagram
class EventCheckoutView {
+post(request, *args, **kwargs)
permission
}
class Event {
+checkin_lists
+log_action(action, data, user, auth)
}
class CheckinList {
+positions_inside
name
}
class OrderPosition {
id
order
}
class Order {
code
}
class perform_checkin {
+perform_checkin(op, clist, ...)
}
EventCheckoutView --> Event : accesses
EventCheckoutView --> CheckinList : iterates
CheckinList --> OrderPosition : positions_inside
OrderPosition --> Order : order
EventCheckoutView --> perform_checkin : calls
File-Level Changes
Possibly 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 @yaxit24 - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- CORS_ALLOW_ALL_ORIGINS=True with CORS_ALLOW_CREDENTIALS=True is insecure for production. (link)
General comments:
- Consider offloading the bulk checkout loop to a background task or batch job to avoid long-running HTTP requests or timeouts when checking out large numbers of attendees.
- The EventCheckoutView defines a
permissionattribute, but DRF expects apermission_classestuple—switch topermission_classesto ensure your permissions are actually enforced. - In CheckinSearchView get_queryset,
not self.has_full_access_permissionis referencing the method itself rather than calling it; you probably neednot self.has_full_access_permission()to enforce the min search length correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider offloading the bulk checkout loop to a background task or batch job to avoid long-running HTTP requests or timeouts when checking out large numbers of attendees.
- The EventCheckoutView defines a `permission` attribute, but DRF expects a `permission_classes` tuple—switch to `permission_classes` to ensure your permissions are actually enforced.
- In CheckinSearchView get_queryset, `not self.has_full_access_permission` is referencing the method itself rather than calling it; you probably need `not self.has_full_access_permission()` to enforce the min search length correctly.
## Individual Comments
### Comment 1
<location> `src/pretix/api/views/checkin.py:1174` </location>
<code_context>
+ auth=auth,
+ )
+
+ response_data = {
+ 'status': 'success' if not errors else 'partial_success',
+ 'checkout_count': checkout_count,
+ 'message': f'Successfully checked out {checkout_count} attendees.'
+ }
+
+ if errors:
+ response_data['errors'] = errors
+ response_data['message'] += f' {len(errors)} errors occurred.'
</code_context>
<issue_to_address>
Returning HTTP 200 even when errors occurred may not be ideal.
Consider using a 207, 400, or 409 status code when errors are present to clearly indicate partial or failed operations to API consumers.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
return Response(response_data, status=status.HTTP_200_OK)
=======
return Response(
response_data,
status=status.HTTP_200_OK if not errors else status.HTTP_207_MULTI_STATUS
)
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/pretix/settings.py:408` </location>
<code_context>
]
# Configure CORS for testing
+CORS_ALLOWED_ORIGINS = [
+'http://localhost:8080']
+
+CORS_ALLOW_ALL_ORIGINS = True
+CORS_ALLOW_CREDENTIALS = True
# Configure the authentication backends
</code_context>
<issue_to_address>
CORS_ALLOW_ALL_ORIGINS=True with CORS_ALLOW_CREDENTIALS=True is insecure for production.
This setup can lead to CSRF and other vulnerabilities; restrict origins and avoid this configuration in production.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Screen.Recording.2025-08-06.at.1.28.58.AM.mov |
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.
|
Thank-you @Sak1012, done. |
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.
As discussed elsewhere, all PRs need to be made against the enext branch. Thanks.


Fixes #822. also refer the issue #38 in Checkin repo.
Summary by Sourcery
Add an endpoint for event-wide attendee checkout and strengthen search behavior in check-in API, alongside CORS and base path configuration updates for testing.
New Features:
Enhancements: