Removes BadgeAndProfile.get_instance

This commit is contained in:
Christopher Neugebauer 2016-04-01 16:58:55 +11:00
parent 28fbacbd28
commit 660e8cb75f
2 changed files with 6 additions and 12 deletions

View file

@ -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

View file

@ -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