diff --git a/participation/models.py b/participation/models.py index 71fd054..1d35f29 100644 --- a/participation/models.py +++ b/participation/models.py @@ -1299,11 +1299,6 @@ class Pool(models.Model): note.set_all(*note_line) note.save() - def save(self, force_insert=False, force_update=False, using=None, update_fields=None): - if os.getenv('GOOGLE_PRIVATE_KEY_ID', None): # Google Sheets support is enabled - self.update_juries_lines_spreadsheet() - super().save(force_insert, force_update, using, update_fields) - def __str__(self): return _("Pool of day {round} for tournament {tournament} with teams {teams}")\ .format(round=self.round, diff --git a/participation/views.py b/participation/views.py index 8491d36..3ff477f 100644 --- a/participation/views.py +++ b/participation/views.py @@ -880,6 +880,13 @@ class PoolUpdateView(VolunteerMixin, UpdateView): return super().dispatch(request, *args, **kwargs) return self.handle_no_permission() + def form_valid(self, form): + ret = super().form_valid(form) + # Update Google Sheets juries lines + if os.getenv('GOOGLE_PRIVATE_KEY_ID', None): + self.object.update_juries_lines_spreadsheet() + return ret + class PoolUpdateTeamsView(VolunteerMixin, UpdateView): model = Pool @@ -1075,6 +1082,10 @@ class PoolJuryView(VolunteerMixin, FormView, DetailView): self.object.juries.add(reg) self.object.save() + # Update Google Sheets juries lines + if os.getenv('GOOGLE_PRIVATE_KEY_ID', None): + self.object.update_juries_lines_spreadsheet() + # Add notification messages.success(self.request, _("The jury {name} has been successfully added!") .format(name=f"{user.first_name} {user.last_name}"))