From 5bc4edf9919e56ce30b1a329f34844022a4aaf8c Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Sat, 18 Mar 2017 16:19:40 +0100 Subject: [PATCH] deny changes to Speaker and Event proposals when call for speakers for the camp is not open --- src/program/models.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/program/models.py b/src/program/models.py index 106ea701..c64fc71c 100644 --- a/src/program/models.py +++ b/src/program/models.py @@ -49,7 +49,6 @@ class CustomUrlStorage(FileSystemStorage): storage = CustomUrlStorage() - class UserSubmittedModel(CampRelatedModel): """ An abstract model containing the stuff that is shared @@ -97,6 +96,22 @@ class UserSubmittedModel(CampRelatedModel): def __str__(self): return '%s (submitted by: %s, status: %s)' % (self.headline, self.user, self.proposal_status) + def save(self, **kwargs): + if not self.camp.call_for_speakers_open: + message = 'Call for speakers is not open' + if hasattr(self, 'request'): + messages.error(self.request, message) + raise ValidationError(message) + super().save(**kwargs) + + def delete(self, **kwargs): + if not self.camp.call_for_speakers_open: + message = 'Call for speakers is not open' + if hasattr(self, 'request'): + messages.error(self.request, message) + raise ValidationError(message) + super().delete(**kwargs) + def get_speakerproposal_picture_upload_path(instance, filename): """ We want speakerproposal pictures saved as MEDIA_ROOT/public/speakerproposals/camp-slug/proposal-uuid/filename """