Update juries lines in Google Sheet after a pool update (not on every save)
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
29b01ebb13
commit
412ff4e067
|
@ -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,
|
||||
|
|
|
@ -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}"))
|
||||
|
|
Loading…
Reference in New Issue