( # type: ignore[return]
self, organisation: typing.Union["Organisation", int]
)
| 288 | return user_organisation.date_joined |
| 289 | |
| 290 | def get_user_organisation( # type: ignore[return] |
| 291 | self, organisation: typing.Union["Organisation", int] |
| 292 | ) -> UserOrganisation: |
| 293 | organisation_id = getattr(organisation, "id", organisation) |
| 294 | |
| 295 | try: |
| 296 | # Since the user list view relies on this data, we prefetch it in |
| 297 | # the queryset, hence we can't use `userorganisation_set.get()` |
| 298 | # and instead use this next(filter()) approach. Since most users |
| 299 | # won't have more than ~1 organisation, we can accept the performance |
| 300 | # hit in the case that we are only getting the organisation for a |
| 301 | # single user. |
| 302 | return next( |
| 303 | filter( |
| 304 | lambda uo: uo.organisation_id == organisation_id, |
| 305 | self.userorganisation_set.all(), |
| 306 | ) |
| 307 | ) |
| 308 | except StopIteration: |
| 309 | logger.warning( |
| 310 | "User %d is not part of organisation %d" % (self.id, organisation_id) |
| 311 | ) |
| 312 | |
| 313 | def get_permitted_projects( |
| 314 | self, |
no test coverage detected