Skip to content

Commit

Permalink
Merge pull request #514 from magfest/group_member_price_bump_fix
Browse files Browse the repository at this point in the history
Group member price bump fix
  • Loading branch information
EliAndrewC committed Sep 4, 2014
2 parents 15ee3c2 + fae3999 commit 8ce7958
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion uber/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ def sorted_attendees(self):
self.attendees.sort(key=lambda a: (a.is_unassigned, a.id != self.leader_id, a.full_name))
return self.attendees

@property
def floating(self):
return [a for a in self.attendees if a.is_unassigned and a.paid == PAID_BY_GROUP]

@property
def new_badge_type(self):
if GUEST_BADGE in {a.badge_type for a in self.attendees}:
Expand Down Expand Up @@ -1329,7 +1333,7 @@ def assign_badges(self, group, new_badge_count):
for i in range(diff):
group.attendees.append(Attendee(badge_type=group.new_badge_type, ribbon=group.new_ribbon, paid=PAID_BY_GROUP))
elif diff < 0:
floating = [a for a in group.attendees if a.is_unassigned and a.paid == PAID_BY_GROUP]
floating = group.floating
if len(floating) < abs(diff):
return 'You cannot reduce the number of badges for a group to below the number of assigned badges'
else:
Expand Down
7 changes: 6 additions & 1 deletion uber/site_sections/preregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,17 @@ def register_group_member(self, session, group_id, message='', **params):
if not message and not params['first_name']:
message = 'First and Last Name are required fields'
if not message:
if session.assign_badges(group, group.badges - 1):
if not group.floating:
raise HTTPRedirect('group_members?id={}&message={}', group_id, 'No more unassigned badges exist in this group')

if attendee.full_name in BANNED_ATTENDEES:
send_banned_email(attendee)

badge_being_claimed = group.floating[0]
attendee.registered = badge_being_claimed.registered
group.attendees.remove(badge_being_claimed)
session.delete(badge_being_claimed)

group.attendees.append(attendee)
attendee.paid = PAID_BY_GROUP
session.add(attendee)
Expand Down

0 comments on commit 8ce7958

Please sign in to comment.