Skip to content

Conversation

@yaxit24
Copy link
Contributor

@yaxit24 yaxit24 commented Aug 4, 2025

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:

  • Implement EventCheckoutView endpoint to check out all attendees of an event
  • Add URL route for the new event checkout endpoint

Enhancements:

  • Require non-empty search term and minimum length for checkin searches without full access
  • Set BASE_PATH to empty string instead of default
  • Introduce CORS middleware and allow all origins for testing

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 4, 2025

Reviewer's Guide

Introduced 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 endpoint

sequenceDiagram
    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
Loading

Class diagram for EventCheckoutView and related check-in logic

classDiagram
    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
Loading

File-Level Changes

Change Details Files
Implemented bulk event checkout endpoint
  • Defined EventCheckoutView for full-event attendee checkout
  • Validated user permissions and event access
  • Iterated checkin lists and positions, performing exit checkins
  • Collected checkout counts and error details
  • Logged action and built success/partial response
src/pretix/api/views/checkin.py
Hardened search API to require non-empty and length-restricted queries
  • Renamed search parameter to search_term
  • Return empty queryset when no search term is provided
  • Enforce minimum search length for users without full access
src/pretix/api/views/checkin.py
Reset BASE_PATH to empty for URL configuration
  • Changed BASE_PATH fallback from '/tickets' to ''
src/pretix/settings.py
Enabled CORS for testing environments
  • Added CorsMiddleware to MIDDLEWARE
  • Configured CORS_ALLOWED_ORIGINS, CORS_ALLOW_ALL_ORIGINS, and CORS_ALLOW_CREDENTIALS
src/pretix/settings.py
Added route for the event checkout API endpoint
  • Registered URL pattern for organizers/.../checkout/
  • Mapped the route to EventCheckoutView
src/pretix/api/urls.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

yaxit24 and others added 7 commits August 5, 2025 01:38
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>
@yaxit24 yaxit24 changed the title Fix: Implement checkout-api changes for Issue #822 Fix: Implement checkout-api changes for Issue Aug 5, 2025
@yaxit24
Copy link
Contributor Author

yaxit24 commented Aug 5, 2025

Screen.Recording.2025-08-06.at.1.28.58.AM.mov

Copy link
Member

@Sak1012 Sak1012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicking on Not Checked In Checks out the attendee although they were never checked in.

Checkin:
Screenshot 2025-08-07 at 11 40 17

Backend:
Screenshot 2025-08-07 at 11 40 33

@yaxit24 yaxit24 requested a review from Sak1012 August 7, 2025 13:42
@yaxit24
Copy link
Contributor Author

yaxit24 commented Aug 7, 2025

Thank-you @Sak1012, done.

@mariobehling mariobehling changed the title Fix: Implement checkout-api changes for Issue feat(checkout-api): implement event-level checkout endpoint and improve search validation Oct 6, 2025
Copy link
Member

@mariobehling mariobehling left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API to enable Checkout

3 participants