-
Notifications
You must be signed in to change notification settings - Fork 103
Add Categories feature for the Badges. #834
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 GuideThis PR introduces category support for badge layouts, enabling automatic layout assignment per item category by extending the data model, forms, views, templates, exporters, and API, with the necessary migration and minor dev settings updates. Sequence diagram for badge rendering with category-based layout assignmentsequenceDiagram
participant System
participant BadgeRenderer
participant Item
participant BadgeLayout
participant ItemCategory
System->>BadgeRenderer: Request badge for Item
BadgeRenderer->>Item: Get item details
BadgeRenderer->>BadgeLayout: Check for item-specific layout
alt No item-specific layout
BadgeRenderer->>ItemCategory: Get item's category
BadgeRenderer->>BadgeLayout: Check for category-specific layout
alt No category-specific layout
BadgeRenderer->>BadgeLayout: Use default layout
end
end
BadgeRenderer-->>System: Return rendered badge
Class diagram for updated BadgeLayout modelclassDiagram
class BadgeLayout {
+id: int
+name: str
+default: bool
+layout: str
+category: ItemCategory
}
class ItemCategory {
+id: int
+name: str
}
BadgeLayout --> ItemCategory : category
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 there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/pretix/plugins/badges/exporters.py:184` </location>
<code_context>
for bi in BadgeItem.objects.select_related('layout').filter(item__event=event)
}
+
+ # Build category-based renderer map
+ category_renderermap = {}
+ for layout in event.badge_layouts.filter(category__isnull=False).select_related('category'):
+ category_renderermap[layout.category_id] = _renderer(event, layout)
+
</code_context>
<issue_to_address>
Consider handling duplicate category assignments for badge layouts.
Currently, assigning multiple layouts to the same category will result in only the last one being used. Consider adding validation or documenting which layout should take precedence.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
# Build category-based renderer map
category_renderermap = {}
for layout in event.badge_layouts.filter(category__isnull=False).select_related('category'):
category_renderermap[layout.category_id] = _renderer(event, layout)
=======
# Build category-based renderer map
category_renderermap = {}
for layout in event.badge_layouts.filter(category__isnull=False).select_related('category'):
if layout.category_id in category_renderermap:
# Validation: Multiple layouts assigned to the same category
raise ValueError(
f"Duplicate badge layout assignment for category ID {layout.category_id}. "
"Each category should have only one badge layout assigned."
)
category_renderermap[layout.category_id] = _renderer(event, layout)
# Note: If you want to allow duplicates and document precedence, comment out the raise and add a comment:
# "If multiple layouts are assigned to the same category, the last one will take precedence."
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
The code changes for the CORS is reverted.
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-16.at.12.18.57.AM.mov |
Fixes #833
Summary by Sourcery
Introduce item category support for badge layouts and integrate category-based filtering and rendering throughout check-in and badge exports
New Features:
Enhancements:
Build:
Chores: