Participant utils
participant.utils:#
country(request)
#
Get the country code of the current participant
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
HttpRequest
|
Http request object |
required |
Returns:
Type | Description |
---|---|
str
|
Country code from: |
Source code in participant/utils.py
get_country_code(ip_address)
#
Get the country code from a given ip address
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ip_address |
str
|
The ip address of the participant |
required |
Returns:
Type | Description |
---|---|
str
|
Country code from: |
Source code in participant/utils.py
get_or_create_participant(request)
#
Get a participant from URL, the session, or create/add a new one
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
HttpRequest
|
Http request object |
required |
Returns:
Type | Description |
---|---|
Participant
|
Participant object from the |
Source code in participant/utils.py
get_participant(request)
#
Get participant object from the session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
HttpRequest
|
Http request object |
required |
Returns:
Type | Description |
---|---|
Participant
|
Participant object linked to the session |
Source code in participant/utils.py
located_in_nl(request)
#
Return True if the requesting IP-address is located in NL
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
HttpRequest
|
Http request object |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether a participant is located in the Netherlands or not. |
Example
Check if the participant is located in the Netherlands
Source code in participant/utils.py
set_participant(request, participant)
#
Set a participant to the current session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
HttpRequest
|
Http request object |
required |
participant |
Participant
|
Participant instance |
required |
Source code in participant/utils.py
visitor_ip_address(request)
#
Get the visitor’s ip address from the request
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
HttpRequest
|
Http request object |
required |
Returns:
Type | Description |
---|---|
str
|
ip address of the participant |