UEWBot / dipvis

Django-based visualiser for tournaments for the boardgame Diplomacy
GNU General Public License v3.0
7 stars 5 forks source link

Need to recalculate scores on deletion of a RoundPlayer #241

Closed UEWBot closed 1 year ago

UEWBot commented 1 year ago

At Carnage, players got points for sitting out rounds, and some players were wrongly flagged as "present", so they got those points. The admin was used to delete the RoundPlayers (this could also have been done from the roll call page), but the Players' total scores still had to be manually adjusted. Presumably the same thing could happen when deleting a GamePlayer?

A quick scan of the Django docs indicates that the Admin goes directly to the database, so we'll need to provide delete_queryset() (and delete_model()?) functions to handle that case. It is also possible to provide a delete() method in a Model, though.

Sounds like the most reliable approach may be to use pre_delete or post_delete signals, but those are only introduced in Django 4.1.

UEWBot commented 1 year ago

RoundPlayers is done. Still need to figure out what we need to do for GamePlayers.

UEWBot commented 1 year ago

GamePlayers are much less likely to be deleted, particularly after a Game has finished, setting GamePlayer.score. There are probably other edge cases around GamePlayer scores for example if you swap two powers after a Game has been scored.

Given that we want to change the way scores are maintained anyway (issue #234), it doesn't seem worth devoting more effort to this at the moment.