[ADD] get_all_characters_from_user function to User API

This commit is contained in:
Peter Pfeufer
2024-01-24 21:03:09 +01:00
parent 13a8b7678f
commit 76ae9b8849
3 changed files with 48 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ They are intended to be used in Alliance Auth itself as well as in the community
These functions are intended to make the life of our community apps developer a little
easier, so they don't have to reinvent the wheel all the time.
## Evecharacter API
## EveCharacter API
### get_main_character_from_evecharacter
@@ -41,6 +41,22 @@ if the `EveCharacter` has no user.
## User API
### get_all_characters_from_user
This is to get all character objects (`EveCharacter`) of a user.
Given we have a `User` object called `my_user` and we want to get all characters:
```python
# Alliance Auth
from allianceauth.framework.api.user import get_all_characters_from_user
characters = get_all_characters_from_user(user=my_user)
```
Now, `characters` is a `list` containing all `EveCharacter` objects of the user.
If the user is `None`, an empty `list` will be returned.
### get_main_character_from_user
This is to get the main character object (`EveCharacter`) of a user.