Removes BadgeAndProfile.get_instance
This commit is contained in:
parent
28fbacbd28
commit
660e8cb75f
2 changed files with 6 additions and 12 deletions
|
@ -48,15 +48,6 @@ class BadgeAndProfile(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Badge for: %s of %s" % (self.name, self.company)
|
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):
|
def save(self):
|
||||||
if not self.name_per_invoice:
|
if not self.name_per_invoice:
|
||||||
self.name_per_invoice = self.name
|
self.name_per_invoice = self.name
|
||||||
|
|
|
@ -55,9 +55,12 @@ def guided_registration(request, page_id=0):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Step 1: Fill in a badge and collect a voucher code
|
# 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
|
# TODO: if voucherform is invalid, make sure that profileform does not save
|
||||||
voucher_form, voucher_handled = handle_voucher(request, "voucher")
|
voucher_form, voucher_handled = handle_voucher(request, "voucher")
|
||||||
profile_form, profile_handled = handle_profile(request, "profile")
|
profile_form, profile_handled = handle_profile(request, "profile")
|
||||||
|
@ -158,7 +161,7 @@ def handle_profile(request, prefix):
|
||||||
attendee = rego.Attendee.get_instance(request.user)
|
attendee = rego.Attendee.get_instance(request.user)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
profile = rego.BadgeAndProfile.objects.get(attendee=attendee)
|
profile = attendee.badgeandprofile
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
profile = None
|
profile = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue