Skip to content

fix: multiple attendances per capability - #815

Open
crosspolar wants to merge 5 commits into
masterfrom
fix/multiple-attendances-per-capability
Open

fix: multiple attendances per capability#815
crosspolar wants to merge 5 commits into
masterfrom
fix/multiple-attendances-per-capability

Conversation

@crosspolar

Copy link
Copy Markdown
Contributor

I've noticed that the current implementation doesn't allow for a notification if there are already members registered with this capability. That's why I've made changes so that the number of slots with this capability is now counted.

@Theophile-Madet

Copy link
Copy Markdown
Collaborator

Is this ready for review?

@Theophile-Madet Theophile-Madet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic is good, I left a few nitpicking comments.

Comment thread tapir/shifts/services/shift_watch_creation_service.py Outdated
user, shift, slots, last_staffing_status=None, staffing_status=None
user,
shift,
last_valid_slot_ids,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those are slots, not ids?

Suggested change
last_valid_slot_ids,
last_valid_slots,

def unregister_first_slot(self):
first_slot = self.slots[0]
first_shift_attendance = ShiftAttendance.objects.filter(slot=first_slot).first()
def unregister_slot(self, slot: ShiftSlot | None = None):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slot parameter is never used.

Comment on lines +233 to +235
self.assertTrue(
ShiftAttendance.objects.filter(slot__in=self.slots[:2]).exists()
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only asserts that at least one of the slots has an attendance, we should check the count to make sure there is two, and probably filter by state too.

Command().handle()
self.assertEqual(0, len(mail.outbox))

# register user to third slot

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that comment really explain anything that is not clear on the following line?

slot_to_register.required_capabilities,
[ShiftUserCapability.SHIFT_COORDINATOR],
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set that value in the test just a few lines above, is this assert necessary?

Co-authored-by: Théophile MADET <theo.madet@posteo.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants