fix argument name

This commit is contained in:
Thomas Steen Rasmussen 2017-07-09 16:54:21 +02:00
parent 4f0de99ea2
commit 38d8c25775

View file

@ -1,15 +1,15 @@
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
def check_speaker_event_camp_consistency(sender, event, **kwargs): def check_speaker_event_camp_consistency(sender, instance, **kwargs):
if kwargs['action'] == 'pre_add': if kwargs['action'] == 'pre_add':
# loop over speakers being added to this event # loop over speakers being added to this event
for pk in kwargs['pk_set']: for pk in kwargs['pk_set']:
# check if this speaker belongs to a different event than the event does # check if this speaker belongs to a different event than the event does
from program.models import Speaker from program.models import Speaker
speaker = Speaker.objects.get(id=pk) speaker = Speaker.objects.get(id=pk)
if speaker.camp != event.camp: if speaker.camp != instance.camp:
raise ValidationError({'speakers': 'The speaker (%s) belongs to a different camp (%s) than the event does (%s)' % (speaker, speaker.camp, event.camp)}) raise ValidationError({'speakers': 'The speaker (%s) belongs to a different camp (%s) than the event does (%s)' % (speaker, speaker.camp, instance.camp)})
def check_speaker_camp_change(sender, instance, **kwargs): def check_speaker_camp_change(sender, instance, **kwargs):