Skip to content

Commit

Permalink
Merge pull request #5197 from onepercentclub/hotfix/BB-20399-fix-fill…
Browse files Browse the repository at this point in the history
…-open-transitions

Fix how activity fills/opens when slots change
  • Loading branch information
gannetson committed Aug 16, 2022
2 parents c1e1bdf + 5eb21e9 commit caab767
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bluebottle/time_based/tests/test_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,36 @@ def test_unfill_slot(self):
self.assertStatus(self.slot2, 'open')
self.assertStatus(self.activity, 'open')

def test_extend_slot_unfills(self):
self.assertStatus(self.activity, 'open')
SlotParticipantFactory.create(slot=self.slot1, participant=self.participant)
participant2 = DateParticipantFactory.create(activity=self.activity)
SlotParticipantFactory.create(slot=self.slot1, participant=participant2)
participant2 = DateParticipantFactory.create(activity=self.activity)
SlotParticipantFactory.create(slot=self.slot2, participant=participant2)
self.assertStatus(self.slot1, 'full')
self.assertStatus(self.slot2, 'full')
self.assertStatus(self.activity, 'full')

self.slot1.capacity = 10
self.slot1.save()
self.assertStatus(self.slot1, 'open')
self.assertStatus(self.activity, 'open')

def test_cancel_open_slot_fills(self):
self.assertStatus(self.activity, 'open')
self.assertStatus(self.slot1, 'open')
SlotParticipantFactory.create(slot=self.slot2, participant=self.participant)
self.assertStatus(self.slot1, 'open')
self.assertStatus(self.slot2, 'full')
self.assertStatus(self.activity, 'open')
self.slot1.states.cancel(save=True)
self.assertStatus(self.activity, 'full')
self.slot3 = DateActivitySlotFactory.create(activity=self.activity)
self.assertStatus(self.activity, 'open')
self.slot3.delete()
self.assertStatus(self.activity, 'full')

def test_fill_new_slot(self):
self.slot_part = SlotParticipantFactory.create(slot=self.slot2, participant=self.participant)
self.assertStatus(self.slot2, 'full')
Expand Down
9 changes: 9 additions & 0 deletions bluebottle/time_based/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,15 @@ class DateActivitySlotTriggers(ActivitySlotTriggers):
activity_has_accepted_participants
]
),
RelatedTransitionEffect(
'activity',
TimeBasedStateMachine.lock,
conditions=[
not_all_slots_finished,
all_slots_will_be_full,
slot_selection_is_free
]
),
ActiveTimeContributionsTransitionEffect(TimeContributionStateMachine.fail)
]
),
Expand Down

0 comments on commit caab767

Please sign in to comment.