mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-12-18 06:45:04 +01:00
[CHANGE] Improve get_all_characters_from_user
### Added - `main_first` option to move the main character to the first position of the character list ### Changed - Character list sorted alphabetically
This commit is contained in:
@@ -43,7 +43,7 @@ if the `EveCharacter` has no user.
|
||||
|
||||
### get_all_characters_from_user
|
||||
|
||||
This is to get all character objects (`EveCharacter`) of a user.
|
||||
This is to get all character objects (`EveCharacter`) of a user (alphabetically sorted).
|
||||
|
||||
Given we have a `User` object called `my_user` and we want to get all characters:
|
||||
|
||||
@@ -51,12 +51,16 @@ Given we have a `User` object called `my_user` and we want to get all characters
|
||||
# Alliance Auth
|
||||
from allianceauth.framework.api.user import get_all_characters_from_user
|
||||
|
||||
characters = get_all_characters_from_user(user=my_user)
|
||||
characters = get_all_characters_from_user(user=my_user, main_first=False)
|
||||
```
|
||||
|
||||
Now, `characters` is a `list` containing all `EveCharacter` objects of the user.
|
||||
If the user is `None`, an empty `list` will be returned.
|
||||
|
||||
The second parameter `main_first` is optional and defaults to `False`.
|
||||
If set to `True`, the function will return the main character as the first
|
||||
item in the list of characters.
|
||||
|
||||
### get_main_character_from_user
|
||||
|
||||
This is to get the main character object (`EveCharacter`) of a user.
|
||||
|
||||
Reference in New Issue
Block a user