Closed willgearty closed 1 month ago
When a new program is created, a financial account is set up with it's name based on the name of the program: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/program/setup.py#L91 https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/accounting/controllers.py#L87-L92
However, when we edit a program, we don't change the name of the account. https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/program/modules/forms/admincore.py#L80-L88
So, let's say you accidentally create a program with the wrong name (let's say, hypothetically, you use next year for the name). You then change the name of the program to the correct name, but the account name remains. If you then go to make a program next year, it will then try to use that same name for the account, but we require account names to be unique, so it throws a database error: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/accounting/models.py#L251-L252
As far as I can tell, the name of these accounts don't matter (they just need to be unique). When we pull this default account, we just look for the account associated with the program that has the smallest ID: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/accounting/controllers.py#L158-L162
So, when we change the name of a program, we should update the name of the account accordingly.
Reported by Stanford.
When a new program is created, a financial account is set up with it's name based on the name of the program: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/program/setup.py#L91 https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/accounting/controllers.py#L87-L92
However, when we edit a program, we don't change the name of the account. https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/program/modules/forms/admincore.py#L80-L88
So, let's say you accidentally create a program with the wrong name (let's say, hypothetically, you use next year for the name). You then change the name of the program to the correct name, but the account name remains. If you then go to make a program next year, it will then try to use that same name for the account, but we require account names to be unique, so it throws a database error: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/accounting/models.py#L251-L252
As far as I can tell, the name of these accounts don't matter (they just need to be unique). When we pull this default account, we just look for the account associated with the program that has the smallest ID: https://github.com/learning-unlimited/ESP-Website/blob/5c9f4b7cd5c2a9cde528f1edd13bcbc2cf3af078/esp/esp/accounting/controllers.py#L158-L162
So, when we change the name of a program, we should update the name of the account accordingly.
Reported by Stanford.