-
Notifications
You must be signed in to change notification settings - Fork 137
Export orders with Wikimedia username #1332
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
Export orders with Wikimedia username #1332
Conversation
Reviewer's GuideAdds a configurable option to include Wikimedia usernames in order exports by annotating orders with the user’s Wikimedia username, conditionally adding a CSV column and values, and wiring the setting through event settings defaults, forms, and templates; also includes minor formatting/import cleanups. Sequence diagram for exporting orders with Wikimedia usernamesequenceDiagram
actor Admin as "Admin"
participant "Event Settings UI" as "Event Settings UI"
participant "Server" as "Server"
participant "EventSettingsForm" as "EventSettingsForm"
participant "Database" as "Database"
participant "Order Exporter" as "Order Exporter"
Admin->>"Event Settings UI": "Open event settings"
"Event Settings UI"->>"Server": "GET event settings form"
"Server"->>"EventSettingsForm": "Instantiate with event settings"
"EventSettingsForm"->>"Database": "Load setting key include_wikimedia_username"
"Database"-->>"EventSettingsForm": "Return current value (default ""False"")"
"EventSettingsForm"-->>"Server": "Rendered form including include_wikimedia_username checkbox"
"Server"-->>"Event Settings UI": "HTML with Wikimedia username option"
Admin->>"Event Settings UI": "Enable include_wikimedia_username and submit"
"Event Settings UI"->>"Server": "POST updated settings (include_wikimedia_username = True)"
"Server"->>"EventSettingsForm": "Validate and save settings"
"EventSettingsForm"->>"Database": "Persist include_wikimedia_username = True for event"
"Database"-->>"EventSettingsForm": "Settings saved"
Admin->>"Order Exporter": "Request order CSV export"
"Order Exporter"->>"Database": "Query events for export and their settings.include_wikimedia_username"
"Database"-->>"Order Exporter": "Events with include_wikimedia_username flags"
"Order Exporter"->>"Database": "Build wikimedia_query: User by email with wikimedia_username"
"Order Exporter"->>"Database": "Query orders with Subquery wikimedia_username annotation"
"Database"-->>"Order Exporter": "Annotated orders result set"
"Order Exporter"->>"Order Exporter": "Check if any event has include_wikimedia_username = True"
"Order Exporter"->>"Order Exporter": "If True, insert Wikimedia username column header before Phone number"
"Order Exporter"->>"Order Exporter": "For each order, insert annotated wikimedia_username value into row"
"Order Exporter"-->>Admin: "CSV file including Wikimedia username column when enabled"
Updated class diagram for order export and event settings with Wikimedia usernameclassDiagram
class EventSettingsForm {
+include_wikimedia_username: bool
+__init__(*args, **kwargs)
}
class DefaultSettingRegistry {
+"include_wikimedia_username": bool
+get_default(key)
}
class Event {
+settings: SettingsProxy
}
class SettingsProxy {
+include_wikimedia_username: bool
+get(key, default)
}
class OrderExporter {
+events: list
+event_object_cache: dict
+iterate_orders(form_data: dict)
}
class Order {
+email: str
+wikimedia_username: str
}
class User {
+email: str
+wikimedia_username: str
}
EventSettingsForm --> DefaultSettingRegistry : "uses setting key 'include_wikimedia_username'"
Event --> SettingsProxy : "has settings including 'include_wikimedia_username'"
OrderExporter --> Event : "reads settings.include_wikimedia_username for each event"
OrderExporter --> Order : "exports annotated orders"
OrderExporter --> User : "subquery by email to annotate wikimedia_username"
Order --> User : "linked logically via matching email for wikimedia_username lookup"
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 there - I've reviewed your changes - here's some feedback:
- When inserting the Wikimedia username into each CSV row, avoid using the hard-coded index 5 and instead compute the insertion index from the headers (e.g., based on the position of the phone number header) to keep columns aligned if the header structure changes.
- You’re annotating wikimedia_username on all orders even if no event has the setting enabled; consider only adding this Subquery when should_include_wikimedia is true to avoid unnecessary DB work on exports where the field is not used.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When inserting the Wikimedia username into each CSV row, avoid using the hard-coded index 5 and instead compute the insertion index from the headers (e.g., based on the position of the phone number header) to keep columns aligned if the header structure changes.
- You’re annotating wikimedia_username on all orders even if no event has the setting enabled; consider only adding this Subquery when should_include_wikimedia is true to avoid unnecessary DB work on exports where the field is not used.
## Individual Comments
### Comment 1
<location> `app/eventyay/base/exporters/orderlist.py:421-424` </location>
<code_context>
order.datetime.astimezone(tz).strftime('%H:%M:%S %Z'),
]
+
+ # Add wikimedia_username if setting is enabled (insert before phone number)
+ if should_include_wikimedia:
+ wikimedia_username = getattr(order, 'wikimedia_username', '') or ''
+ row.insert(5, wikimedia_username)
+
try:
</code_context>
<issue_to_address>
**issue (bug_risk):** Hard-coding the column index 5 for wikimedia_username risks misalignment with the headers.
This relies on column 5 always being the Wikimedia username position. If the header structure changes (e.g., different name formats or new fields), this index can become wrong and misalign data and headers. Instead, derive the insertion index dynamically (e.g., find the phone column index at runtime) or share the same column-ordering logic used when building the headers so rows always match the header definition.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 adds functionality to export Wikimedia usernames in order exports. The feature is controlled by a new event setting include_wikimedia_username that allows organizers to include Wikimedia IDs for users authenticated via Wikimedia in their order export files.
- Adds a new boolean event setting
include_wikimedia_usernamewith UI controls - Modifies the order export logic to fetch and conditionally include Wikimedia username data
- Updates imports ordering in affected files
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/eventyay/base/configurations/default_setting.py | Defines the new include_wikimedia_username boolean setting with default value 'False' |
| app/eventyay/control/forms/event.py | Adds the new setting to the event settings form and reorders imports alphabetically |
| app/eventyay/control/templates/pretixcontrol/event/settings.html | Adds UI field for the Wikimedia username setting in the customer data section |
| app/eventyay/base/exporters/orderlist.py | Implements logic to fetch Wikimedia username via subquery and conditionally include it in CSV exports |
| app/eventyay/control/views/orders.py | Reorders imports alphabetically |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Part of #1214
Summary by Sourcery
Add optional inclusion of Wikimedia usernames in order exports based on a new event setting.
New Features:
Enhancements: