Skip to content

Commit

Permalink
Unconfirm unexpected feedback based on prefs
Browse files Browse the repository at this point in the history
If teams are only expected to submit feedback on the orallist, if there
are multiple submissions from the same debate team to different adjs,
there is a problem. The feedback should then be unconfirmed as to not
affect the scores of unexpected adjs.

Fixes #473
  • Loading branch information
tienne-B committed Mar 3, 2021
1 parent 02886a1 commit ce09375
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tabbycat/adjfeedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ def __str__(self):
time=('<unknown>' if self.timestamp is None else str(
self.timestamp.isoformat())))

def _unique_unconfirm_args(self):
kwargs = super()._unique_unconfirm_args()
if self.source_team is not None and self.source_team.debate.round.tournament.pref('feedback_from_teams') != 'all-adjs':
kwargs.pop('adjudicator')
return kwargs

@cached_property
def source(self):
if self.source_adjudicator:
Expand Down
5 changes: 4 additions & 1 deletion tabbycat/results/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def _unique_filter_args(self):
return dict((arg, getattr(self, arg)) for arg in self._meta.unique_together[0]
if arg != 'version')

def _unique_unconfirm_args(self):
return self._unique_filter_args

def save(self, *args, **kwargs):
# Use a lock to protect against the possibility that two submissions do this
# at the same time and get the same version number or both be confirmed.
Expand All @@ -85,7 +88,7 @@ def save(self, *args, **kwargs):
# Check for uniqueness.
if self.confirmed:
unconfirmed = self.__class__.objects.filter(confirmed=True,
**self._unique_filter_args).exclude(pk=self.pk).update(confirmed=False)
**self._unique_unconfirm_args()).exclude(pk=self.pk).update(confirmed=False)
if unconfirmed > 0:
logger.info("Unconfirmed %d %s so that %s could be confirmed", unconfirmed, self._meta.verbose_name_plural, self)

Expand Down

0 comments on commit ce09375

Please sign in to comment.