| 459 | unique_together = ("organisation", "external_id") |
| 460 | |
| 461 | def add_users_by_id(self, user_ids: list): # type: ignore[no-untyped-def,type-arg] |
| 462 | users_to_add = list( |
| 463 | FFAdminUser.objects.filter(id__in=user_ids, organisations=self.organisation) |
| 464 | ) |
| 465 | if len(user_ids) != len(users_to_add): |
| 466 | missing_ids = set(users_to_add).difference({u.id for u in users_to_add}) |
| 467 | raise FFAdminUser.DoesNotExist( |
| 468 | "Users %s do not exist in this organisation" % ", ".join(missing_ids) |
| 469 | ) |
| 470 | self.users.add(*users_to_add) |
| 471 | |
| 472 | def remove_users_by_id(self, user_ids: list): # type: ignore[no-untyped-def,type-arg] |
| 473 | self.users.remove(*user_ids) |