mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
[ADD] API docu
This commit is contained in:
parent
003a67224e
commit
eebeb26001
@ -4,8 +4,37 @@
|
|||||||
|
|
||||||
### get_main_character_from_user
|
### get_main_character_from_user
|
||||||
|
|
||||||
|
This is to get the main character object (`EveCharacter`) of a user.
|
||||||
|
|
||||||
|
Given we have a `User` object called `my_user` and we want to get the main character:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Alliance Auth
|
||||||
|
from allianceauth.framework.api.user import get_main_character_from_user
|
||||||
|
|
||||||
|
main_character = get_main_character_from_user(user=my_user)
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, `main_character` is an `EveCharacter` object, or `None` if the user has no main
|
||||||
|
character or the user is `None`.
|
||||||
|
|
||||||
### get_main_character_name_from_user
|
### get_main_character_name_from_user
|
||||||
|
|
||||||
|
This is to get the name of the main character of a user.
|
||||||
|
|
||||||
|
Given we have a `User` object called `my_user` and we want to get the main character name:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Alliance Auth
|
||||||
|
from allianceauth.framework.api.user import get_main_character_name_from_user
|
||||||
|
|
||||||
|
main_character = get_main_character_name_from_user(user=my_user)
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, `main_character` is a `string` containing the user's main character name.
|
||||||
|
If the user has no main character, the username will be returned. If the user is `None`,
|
||||||
|
the sentinel username (see [get_sentinel_user](#get-sentinel-user)) will be returned.
|
||||||
|
|
||||||
### get_sentinel_user
|
### get_sentinel_user
|
||||||
|
|
||||||
This function is useful in models when using `User` model-objects as foreign keys.
|
This function is useful in models when using `User` model-objects as foreign keys.
|
||||||
@ -15,6 +44,7 @@ deleted. To keep the data, you can have Django map this to the sentinel user.
|
|||||||
Import:
|
Import:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
# Alliance Auth
|
||||||
from allianceauth.framework.api.user import get_sentinel_user
|
from allianceauth.framework.api.user import get_sentinel_user
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user