deny changes to Speaker and Event proposals when call for speakers for the camp is not open

This commit is contained in:
Thomas Steen Rasmussen 2017-03-18 16:19:40 +01:00
parent 027e89e4ab
commit 5bc4edf991

View file

@ -49,7 +49,6 @@ class CustomUrlStorage(FileSystemStorage):
storage = CustomUrlStorage() storage = CustomUrlStorage()
class UserSubmittedModel(CampRelatedModel): class UserSubmittedModel(CampRelatedModel):
""" """
An abstract model containing the stuff that is shared An abstract model containing the stuff that is shared
@ -97,6 +96,22 @@ class UserSubmittedModel(CampRelatedModel):
def __str__(self): def __str__(self):
return '%s (submitted by: %s, status: %s)' % (self.headline, self.user, self.proposal_status) 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): def get_speakerproposal_picture_upload_path(instance, filename):
""" We want speakerproposal pictures saved as MEDIA_ROOT/public/speakerproposals/camp-slug/proposal-uuid/filename """ """ We want speakerproposal pictures saved as MEDIA_ROOT/public/speakerproposals/camp-slug/proposal-uuid/filename """