Currently it's a butt-ton of work to find out what ticket type a user has; it requires a bunch of queries to find all the line items of category TICKET_PRODUCT_CATEGORY attached to an invoice with STATUS_PAID attached to a user attached to the attendee in question.
All of this could be avoided with a small amount of de-normalisation; rather than setting has_registered to TRUE, set it to a string - the name of the item from TICKET_PRODUCT_CATEGORY. Or perhaps make it a foreignkey that points directly to the lineitem in question, so that it's simple to verify that attendee.user.has_registered.invoice.status still == STATUS_PAID
Alternative suggestions: make a new field ticket_type that does this, that always gets set/unset at the same time as has_registered. Or, make the new field ticket_type, and make has_registered into a property which is just a proxy for testing whether or not ticket_type is empty.
Currently it's a butt-ton of work to find out what ticket type a user has; it requires a bunch of queries to find all the line items of category TICKET_PRODUCT_CATEGORY attached to an invoice with STATUS_PAID attached to a user attached to the attendee in question.
All of this could be avoided with a small amount of de-normalisation; rather than setting has_registered to TRUE, set it to a string - the name of the item from TICKET_PRODUCT_CATEGORY. Or perhaps make it a foreignkey that points directly to the lineitem in question, so that it's simple to verify that attendee.user.has_registered.invoice.status still == STATUS_PAID
Alternative suggestions: make a new field ticket_type that does this, that always gets set/unset at the same time as has_registered. Or, make the new field ticket_type, and make has_registered into a property which is just a proxy for testing whether or not ticket_type is empty.