diff --git a/registrasion/models.py b/registrasion/models.py index d9ddfc1e..92babf1b 100644 --- a/registrasion/models.py +++ b/registrasion/models.py @@ -48,15 +48,6 @@ class BadgeAndProfile(models.Model): def __str__(self): return "Badge for: %s of %s" % (self.name, self.company) - @staticmethod - def get_instance(attendee): - ''' Returns either None, or the instance that belongs - to this attendee. ''' - try: - return BadgeAndProfile.objects.get(attendee=attendee) - except ObjectDoesNotExist: - return None - def save(self): if not self.name_per_invoice: self.name_per_invoice = self.name diff --git a/registrasion/views.py b/registrasion/views.py index 230227c7..1539c846 100644 --- a/registrasion/views.py +++ b/registrasion/views.py @@ -55,9 +55,12 @@ def guided_registration(request, page_id=0): ) # Step 1: Fill in a badge and collect a voucher code - profile = rego.BadgeAndProfile.get_instance(attendee) + try: + profile = attendee.badgeandprofile + except ObjectDoesNotExist: + profile = None - if profile is None: + if not profile: # TODO: if voucherform is invalid, make sure that profileform does not save voucher_form, voucher_handled = handle_voucher(request, "voucher") profile_form, profile_handled = handle_profile(request, "profile") @@ -158,7 +161,7 @@ def handle_profile(request, prefix): attendee = rego.Attendee.get_instance(request.user) try: - profile = rego.BadgeAndProfile.objects.get(attendee=attendee) + profile = attendee.badgeandprofile except ObjectDoesNotExist: profile = None