Skip to content

Conversation

@Sak1012
Copy link
Member

@Sak1012 Sak1012 commented Nov 25, 2025

This PR fixes a few 500 errors caused due to item -> product rename like accessing the "My Events" page

image

Summary by Sourcery

Align event data and UI flows with the new product naming to prevent runtime errors related to the item→product migration.

Bug Fixes:

  • Fix JSON export of events to correctly use products instead of items in products, order positions, and quotas payloads.
  • Fix PDF upload preview generation by creating and referencing sample products instead of items in orders.
  • Prevent event cancellation from failing by deactivating products and logging product change actions instead of items.
  • Ensure tax rule deletion checks correctly validate against products that use the tax rule.
  • Fix check-in form configuration by sourcing limitable products from the event’s products queryset.
  • Correct event settings and event list templates to link to product creation and quota management routes using the updated product URLs.

@Sak1012 Sak1012 requested a review from mariobehling November 25, 2025 19:49
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 25, 2025

Reviewer's Guide

This PR completes the migration from the old item-based API/model naming to product-based naming across JSON export, PDF preview generation, event cancellation, check-in forms, tax rule deletion checks, and several control templates, fixing 500 errors caused by stale item references.

Sequence diagram for event JSON export using products instead of items

sequenceDiagram
  actor Organizer
  participant ControlPanel
  participant JSONExporter
  participant Event
  participant ProductManager as EventProducts
  participant OrderPositions

  Organizer->>ControlPanel: Request_event_JSON_export
  ControlPanel->>JSONExporter: render(event)
  JSONExporter->>Event: get_categories()
  Event-->>JSONExporter: categories_queryset
  JSONExporter->>ProductManager: event.products.select_related_tax_rule_prefetch_variations
  ProductManager-->>JSONExporter: products_queryset
  loop For_each_product
    JSONExporter->>ProductManager: access_product_fields_and_variations
    ProductManager-->>JSONExporter: product_data_and_variations
  end
  JSONExporter->>OrderPositions: get_positions_for_event
  OrderPositions-->>JSONExporter: positions_with_product_and_variation
  loop For_each_position
    JSONExporter->>OrderPositions: read_product_id_price_and_attendee_data
    OrderPositions-->>JSONExporter: position_data_with_product_id
  end
  JSONExporter->>Event: get_quotas_with_products_and_variations
  Event-->>JSONExporter: quotas_queryset
  loop For_each_quota
    JSONExporter->>Event: quota.products_and_variations
    Event-->>JSONExporter: product_ids_and_variation_ids
  end
  JSONExporter-->>ControlPanel: JSON_payload_with_products
  ControlPanel-->>Organizer: Return_JSON_response
Loading

File-Level Changes

Change Details Files
Update JSON export structure and queries from items to products to align with the new product model and prevent crashes.
  • Rename exported collection from items to products and update all per-entry keys and loop variables from item to product
  • Switch event query from self.event.items to self.event.products including related prefetch/select logic
  • Update variation price fallback and queryset to reference product instead of item
  • Change order position payload from using item to product and adjust quota exports from items to products including prefetch_related
app/eventyay/base/exporters/json.py
Adjust PDF preview generation to create and use product-based order positions instead of item-based ones.
  • Create sample products via event.products.create instead of event.items.create
  • Update order.positions.create calls to use product and product2 fields instead of item and item2
  • Ensure prices reference the correct product.default_price values
app/eventyay/control/views/pdf.py
Ensure event cancellation deactivates products and logs the correct product-related action.
  • Iterate over event.products instead of event.items when deactivating on cancel
  • Update the logged action identifier from pretix.event.item.changed to pretix.event.product.changed
app/eventyay/base/services/cancelevent.py
Align check-in forms with the new product queryset field for limiting products.
  • Set limit_products queryset from event.products instead of event.items in both check-in list forms
app/eventyay/control/forms/checkin.py
Update tax rule deletion guardrails to look for attached products instead of items.
  • Change the existence check from self.event.items.filter(tax_rule=self) to self.event.products.filter(tax_rule=self) in allow_delete
app/eventyay/base/models/tax.py
Fix control templates to use product-based URL names instead of item-based ones.
  • Update the settings_base template link from control:event.items.add to control:event.products.add for creating the first product
  • Change events index quota link from control:event.items.quotas to control:event.products.quotas
app/eventyay/eventyay_common/templates/eventyay_common/event/settings_base.html
app/eventyay/eventyay_common/templates/eventyay_common/events/index.html

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 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> `app/eventyay/control/views/pdf.py:87` </location>
<code_context>
-        order.positions.create(item=item2, attendee_name_parts=sample, price=item.default_price, addon_to=p)
-        order.positions.create(item=item2, attendee_name_parts=sample, price=item.default_price, addon_to=p)
+        p = order.positions.create(product=product, attendee_name_parts=sample, price=product.default_price)
+        order.positions.create(product=product2, attendee_name_parts=sample, price=product.default_price, addon_to=p)
+        order.positions.create(product=product2, attendee_name_parts=sample, price=product.default_price, addon_to=p)

</code_context>

<issue_to_address>
**issue (bug_risk):** Use product2.default_price when creating positions for product2 to avoid inconsistent sample data.

These two positions are for `product2`, but both use `product.default_price` instead of `product2.default_price`. This makes the sample position prices inaccurate and could hide layout issues that depend on the correct price. Please switch both lines to use `product2.default_price` so each sample position matches its product’s default price.
</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.

Copy link
Contributor

Copilot AI left a 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 addresses 500 errors caused by incomplete migration from item to product terminology across the eventyay codebase. The changes ensure consistency in variable names, model field references, URL patterns, and log actions.

  • Updates URL patterns and template references from event.items to event.products
  • Renames variables and model field parameters from item to product
  • Updates JSON export structure to use products instead of items

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
app/eventyay/eventyay_common/templates/eventyay_common/events/index.html Updates URL pattern for quota management from event.items.quotas to event.products.quotas
app/eventyay/eventyay_common/templates/eventyay_common/event/settings_base.html Updates URL pattern for product creation from event.items.add to event.products.add
app/eventyay/control/views/pdf.py Renames variables and updates OrderPosition creation to use product= parameter instead of item=
app/eventyay/control/forms/checkin.py Updates queryset from event.items.all() to event.products.all() for check-in form product limits
app/eventyay/base/services/cancelevent.py Updates queryset and log action when deactivating products during event cancellation
app/eventyay/base/models/tax.py Updates validation in allow_delete method to check event.products instead of event.items
app/eventyay/base/exporters/json.py Updates JSON export structure to use products key and product_id field references throughout

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sak1012 Sak1012 merged commit ed8b429 into fossasia:enext Nov 25, 2025
8 checks passed
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.

1 participant