fix bug in speaker<>camp relationship validation in signal handler
This commit is contained in:
parent
034543595a
commit
4f0de99ea2
|
@ -1,13 +1,16 @@
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
def check_speaker_event_camp_consistency(sender, instance, **kwargs):
|
|
||||||
|
def check_speaker_event_camp_consistency(sender, event, **kwargs):
|
||||||
if kwargs['action'] == 'pre_add':
|
if kwargs['action'] == 'pre_add':
|
||||||
|
# loop over speakers being added to this event
|
||||||
for pk in kwargs['pk_set']:
|
for pk in kwargs['pk_set']:
|
||||||
# check if this event belongs to a different event than the speaker does
|
# check if this speaker belongs to a different event than the event does
|
||||||
from program.models import Event
|
from program.models import Speaker
|
||||||
event = Event.objects.get(id=pk)
|
speaker = Speaker.objects.get(id=pk)
|
||||||
if event.camp != instance.camp:
|
if speaker.camp != event.camp:
|
||||||
raise ValidationError({'events': 'One or more events belong to a different camp (%s) than the speaker (%s) does' % (event.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)})
|
||||||
|
|
||||||
|
|
||||||
def check_speaker_camp_change(sender, instance, **kwargs):
|
def check_speaker_camp_change(sender, instance, **kwargs):
|
||||||
if instance.pk:
|
if instance.pk:
|
||||||
|
|
Loading…
Reference in a new issue