Fix register-for-somebody-else wrt special reg types
authorMagnus Hagander <magnus@hagander.net>
Mon, 5 Feb 2018 12:27:40 +0000 (13:27 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 5 Feb 2018 12:27:40 +0000 (13:27 +0100)
For a register-for-somebody-else, the attendee is actually NULL when we
try to validate the registration type. We need to especially forbid this
case - those that use these regtypes will just have to make individual
registrations, as they have to be mapped to the actual user account.

postgresqleu/confreg/regtypes.py

index 55c6ad957e060cae37ee433cec23c6f17ebe64ea..59462446b010087eb00dfa58f539415affcd6e85 100644 (file)
@@ -7,6 +7,8 @@ def validate_speaker_registration(reg):
        # This registration is only available if a speaker is *confirmed*
        # at this conference.
        from models import ConferenceSession
+       if reg.attendee is None:
+               raise ValidationError('Speaker registrations have to be done by the speaker directly')
        if not ConferenceSession.objects.filter(conference=reg.conference,
                                                                                        speaker__user=reg.attendee,
                                                                                        status=1, # approved
@@ -22,6 +24,8 @@ def validate_speaker_or_reserve_registration(reg):
        # This registration is only available if a speaker is *confirmed*
        # or *reserve listed* at this conference.
        from models import ConferenceSession
+       if reg.attendee is None:
+               raise ValidationError('Speaker registrations have to be done by the speaker directly')
        if not ConferenceSession.objects.filter(conference=reg.conference,
                                                                                        speaker__user=reg.attendee,
                                                                                        status__in=(1,4), # approved/reserve
@@ -34,6 +38,8 @@ _specialregtypes['spkr'] = {
        }
 
 def validate_staff_registration(reg):
+       if reg.attendee is None:
+               raise ValidationError('Staff registrations have to be done by the attendee directly')
        if not reg.conference.staff.filter(pk=reg.attendee.pk).exists():
                raise ValidationError('This registration type is only available if you are confirmed staff at this conference')