-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add Checkin API and Badge Preview and Download Feature #420
base: development
Are you sure you want to change the base?
Conversation
Fixed Checkin API to handle requests with Device Authorization and to include badge url in the response if the plugin is enabled and also add preview functionalites
Reviewer's Guide by SourceryThis PR implements a new CheckIn API and adds badge preview/download functionality for the check-in process. The changes include extensive refactoring of the check-in logic into smaller, more maintainable functions, addition of new API endpoints for badge operations, and implementation of CORS support to enable cross-origin requests from the check-in application. Sequence diagram for Checkin Redeem ProcesssequenceDiagram
actor User
participant CheckinRedeemView
participant _redeem_process
participant Checkin
participant BadgeOutputProvider
User->>CheckinRedeemView: POST /checkin/redeem
CheckinRedeemView->>_redeem_process: Call _redeem_process
_redeem_process->>Checkin: perform_checkin
alt Badge Plugin Enabled
_redeem_process->>BadgeOutputProvider: generate badge
BadgeOutputProvider-->>_redeem_process: Return badge PDF
end
_redeem_process-->>CheckinRedeemView: Return Response
CheckinRedeemView-->>User: Response with status
Updated class diagram for Checkin and Badge ModelsclassDiagram
class Checkin {
+require_checkin_attention: bool
}
class BadgeOutputProvider {
+generate(OrderPosition) Tuple
+settings_form_fields
}
class CheckinRedeemInputSerializer {
+lists
+secret
+force
+source_type
+type
+ignore_unpaid
+questions_supported
+nonce
+datetime
+answers
}
Checkin <|-- CheckinRedeemInputSerializer
BadgeOutputProvider <|-- CheckinRedeemInputSerializer
Checkin <|-- BadgeOutputProvider
File-Level Changes
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 @Sak1012 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
return downloads | ||
|
||
|
||
def _redeem_process(*, checkinlists, raw_barcode, answers_data, dateandtime, |
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.
issue (complexity): Consider extracting check-in business logic into a dedicated service layer to separate concerns.
The check-in logic has become overly complex by mixing business operations with API concerns. Consider refactoring into a service layer:
class CheckInService:
def __init__(self, checkinlists):
self.list_by_event = self._validate_checkinlists(checkinlists)
def process_checkin(self, barcode, checkin_args):
# Core business logic steps:
position = self._find_ticket_position(barcode)
self._validate_position(position)
return self._perform_checkin(position, checkin_args)
def _find_ticket_position(self, barcode):
# Ticket lookup logic
pass
def _validate_position(self, position):
# Validation rules
pass
def _perform_checkin(self, position, args):
# Check-in execution
pass
Then the API view becomes simpler:
def redeem(self, request):
service = CheckInService(checkinlists)
result = service.process_checkin(
barcode=request.data['secret'],
checkin_args={'type': request.data['type'], ...}
)
return self._format_response(result)
This separates concerns and makes the code more maintainable while preserving functionality.
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.
Please ensure tests are passing.
<button class="btn btn-default btn-block" id="editor-add-poweredby" | ||
data-content="dark" | ||
disabled> | ||
<span class="fa fa-image"></span> | ||
{% trans "pretix Logo" %} | ||
{% trans "Eventyay Logo" %} |
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.
eventyay Logo
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.
Done 👍
I have made the necessary modifications 👍 |
deployment/docker/nginx.conf
Outdated
@@ -47,6 +47,22 @@ http { | |||
server_name _; | |||
index index.php index.html; | |||
root /var/www; | |||
|
|||
add_header 'Access-Control-Allow-Origin' 'https://checkin.eventyay.com' always; |
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.
Please change this into a variable. So we can use different URLs, e.g. for the development branch.
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.
How about using wildcard *
to allow all "origin"?
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.
Well, for partners such as Wikimedia we also want to deploy it to different domains.
src/pretix/settings.py
Outdated
@@ -373,6 +373,8 @@ | |||
} | |||
|
|||
MIDDLEWARE = [ | |||
'corsheaders.middleware.CorsMiddleware', |
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.
You should remove this middleware to test if the Nginx config works.
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.
Done 👍
deployment/docker/nginx.conf
Outdated
@@ -47,6 +47,22 @@ http { | |||
server_name _; | |||
index index.php index.html; | |||
root /var/www; | |||
|
|||
add_header 'Access-Control-Allow-Origin' 'https://checkin.eventyay.com' always; |
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.
How about using wildcard *
to allow all "origin"?
3c6277d
to
5c51706
Compare
This PR let's organisers perform Checkin from Open-event-checkin with the new CheckIn API and also facilitates badge preview, printing and downloading functionalities at checkin.
Summary by Sourcery
Add a new Checkin API and badge preview, printing, and downloading features to enhance the check-in process. Implement PDF rendering support and configure CORS headers for cross-origin requests.
New Features:
Enhancements:
Deployment: