svthalia / concrexit

Thalia Website built on Django.
https://thalia.nu
Other
22 stars 11 forks source link

WIP: Payment.payable_object property to get payable #3737

Open DeD1rk opened 1 week ago

DeD1rk commented 1 week ago

Supersedes #2126. Closes #1957. Closes #2034.

Summary

This makes use of prefetching the .payment OneToOneFields' reverse relations to efficiently get the payable for payments.

As this does not introduce a duplicate relation in the database, it should be more robust. In the long term, I do think moving to only a GenericForeignKey from Payment to payable would be better, that seems like a change that is very likely to break something. So I'd rather just get this working properly in a way that is certain not to break stuff.

Replacing the 1to1's with a reverse generic FK would still be nice to do some day, but I don't think we should have both as in #2126.

TODO:

How to test

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'