- 
                Notifications
    
You must be signed in to change notification settings  - Fork 124
 
feat(badges): add categories support for badge layouts and filtering #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: enext
Are you sure you want to change the base?
Conversation
* Fix: Export check-in list to PDF with HTML questions * Improve per sourcery-ai comment
* Improve error message when exporting orders failed * Improve exception catching
* fix: Moved email-content to Templates tab under Mails * implemented sourcery-ai suggestions * replace deprecated with modern syntax
* Update views.py * Update views.py * Update views.py here updated changes as asked by Auswin
…a#752) * chore: rename the mails page heading to match the sidebar menu item * implemented sourcery-ai suggestions
* Added text tab in eventyay-common control * Added a success message * Correct logic from previous commit
* Refactor: Consolidate General Event Settings to eventyay_common * formatting changes * updates * Fix issue with saving event settings form in ticket and common component * formatting fixes * removed event>location autosuggestions
* Fix: the reviews * Fix: removed the @media fadeIn * fix: additional adjustments for fropdoem menu * Update main.scss for the 800*1280 working of the submenu * Update utils.js for the submenu fix in the 800*1280 * Update main.scss, with the z-index vales * Update main.scss. updated the z-index to lower values * Update main.scss. updated the z index to 10s and 20s --------- Co-authored-by: Your Name <you@example.com>
* Fix: Missing menu in Ticket Buying page * Prevent attaching event handler many times
…ia#799) * fix: Tickets General settings crash due to unused kwarg value * fix: Tickets General settings crash due to unused kwarg value
* Render "Join Video" link in email * Fix usage of %s format in logging * Prevent circular import of Order by dropping the Typing --------- Co-authored-by: Norbert Preining <norbert@preining.info>
          
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 | 
    
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 make this PR against the enext branch.
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: